[Rd] possible bug in formals

Uwe Ligges ligges at statistik.tu-dortmund.de
Sun May 23 16:20:01 CEST 2010



On 23.05.2010 16:14, Josef Leydold wrote:
> Hi,
>
> I am a little bit surprised by the following output of
> 'formals'. Is this the intended behavior?
>
>> f<- function(a=1,b=-1) { a+b }
>> class(formals(f)$a)
> [1] "numeric"
>> class(formals(f)$b)
> [1] "call"
>
>
> Josef
>
>


Yes, the arguments have not yet been evaluated, hence -1 is still a 
language object.

Try to write
  f<- function(a= +1, b= -1) { a+b }
and you will find that this is a fascinating feature.

Uwe Ligges



More information about the R-devel mailing list