[Rd] Warning when calling formals() for `[`.

Laurent Gautier lg@utier @ending from gm@il@com
Sat Oct 6 19:52:56 CEST 2018


Hi,

Thanks for the note. How would explain the following snippet taken from
`formals` doc page (the code comment is also from that doc) ?

## formals returns NULL for primitive functions.  Use it in combination with
     ## args for this case.
     is.primitive(`+`)
     formals(`+`)
     formals(args(`+`))



Le sam. 6 oct. 2018 à 13:42, Rui Barradas <ruipbarradas using sapo.pt> a écrit :

> Hello,
>
> I believe that this is maybe not a *feature* but at least expected
> behaviour.
>
> The call formals(args(`[`)) breaks down to
>
>
>  > args(`[`)
> NULL
>  > formals(NULL)
> NULL
> Warning message:
> In formals(fun) : argument is not a function
>
>
> Hope this helps,
>
> Rui Barradas
>
>
> Às 18:26 de 06/10/2018, Laurent Gautier escreveu:
> > Hi,
> >
> > A short code example showing the warning might the only thing needed
> here:
> >
> > ```
> >> formals(args(`[`))
> > NULL
> >
> > *Warning message:In formals(fun) : argument is not a function*
> >> is.function(`[`)
> > [1] TRUE
> >> is.primitive(`[`)
> > [1] TRUE
> > ```
> >
> > Now with an other primitive:
> >
> > ```
> >> formals(args(`sum`))
> > $...
> >
> >
> > $na.rm
> > [1] FALSE
> >
> >> is.function(`sum`)
> > [1] TRUE
> >> is.primitive(`sum`)
> > [1] TRUE
> >> class(`[`)
> > [1] "function"
> > ```
> >
> > Is this a feature ?
> >
> >
> > Laurent
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-devel using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list