R-alpha: length and as.list on functions

Robert Gentleman (rgentlem@stat.auckland.ac.nz)
Tue, 9 Apr 1996 13:45:40 +1200

Date: Tue, 9 Apr 1996 13:45:40 +1200
From: Robert Gentleman <rgentlem@stat.auckland.ac.nz>
Message-Id: <199604090145.NAA02401@stat.auckland.ac.nz>
To: R-testers@stat.math.ethz.ch
Subject: R-alpha: length and as.list on functions

A while ago Martin complained about


and wanted 


to work when fun was a function.
We made one small fix to the first; we return 0 if the argument
to length isn't a vector or something that is inherently a list.
I would like to switch this to an error message if length is applied
to any object for which length is not a sensible measure. 

For the second problem I'm not sure what you should get back.
I really don't like the S version, which is a list of length
number of args + 1.
In R I would prefer to signal an error as well (which is what we do
now). But as a second choice we could return a list of length 3.
The formals, the body and the environment. I don't like this because
it has to allow access to the formals in a not nice way and some
of the internal bits (like our missing argument indicator may 
escape). S actually has things of mode missing. 

I haven't been able to figure out why you would want access to the
body of the function. Any suggestions about where and why this would be

r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch