[Rd] Getting param names of primitives

Duncan Murdoch murdoch at stats.uwo.ca
Wed Jul 11 16:11:04 CEST 2007


On 7/11/2007 9:40 AM, Seth Falcon wrote:
> Prof Brian Ripley <ripley at stats.ox.ac.uk> writes:
> 
>> My problem is that if we make formals() work on primitives, people will 
>> expect
>>
>> formals(log) <- value
>>
>> to work, and it cannot.
> 
> But it could give an informative error message.  Asking for formals()
> seems to make sense so making it work seems like a good idea.  I'll
> agree that it working might encourage someone to try formals<-(), but
> the fact that it cannot do anything but error seems like a strange
> reason not to make formals() work.

But primitives don't have formals, and that's why you can't set them. 
Having formals(primitive) work just makes it harder to talk about the 
language.  Closures have formals, primitives don't.  Both have args.  If 
you want to work with the args of a function, use the args.

Duncan Murdoch



More information about the R-devel mailing list