On Tuesday 17 April 2007 09:12, Prof Brian Ripley wrote: > On Mon, 16 Apr 2007, Thomas Friedrichsmeier wrote:
[...] > > While at it, I was wondering, why > > > > formals(c) > > > > still returns NULL, in contrast. > > Because only closures have formals, the way things are defined. This > makes sense to me as formals<-() cannot work on primitives. On the other hand, a return value of NULL does not differentiate between a closure which simply does not have any formals and a primitive: f <- function () 1 formals (f) # NULL formals (c) # NULL In the former case, formals<-() will work, in the latter case, it won't. To differentiate between those, one could use is.primitive() or typeof(). I don't pretend to understand the technicalities involved, but to me it looks like there is some effort to make all types of functions "look" the same in R for most purposes. Having the same in formals() would make it slightly easier to provide argument completion or object browsers (but then, args() could be used for such purposes). Either way it's painless to me, and is now clearly documented. So if this does not make too much sense, just ignore me. Regards Thomas Friedrichsmeier ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel