[Rd] Another wishlist for R
Thomas Lumley
tlumley at u.washington.edu
Fri Jan 16 19:12:38 MET 2004
On Fri, 16 Jan 2004, Kevin Wright wrote:
>
> 10. More uniformity in quoting arguments.
> Uniformity outweighs cleverness/exceptions ("The Art of Unix Programming").
> Functions accepting non-quoted arguments
> is.function(obj)
> args(predict)
> rm(a)
> help(help)
> find(replace) or find("replace")
> Functions requiring quoted arguments
> get("help")
> exists("predict.lme")
>
> Some people have claimed "the designers of S knew what they were
> doing" because you can do clever things like this:
> i="help"
> exists(i)
> But we could just as easily be doing other clever things
> and have more uniform quoting rules. S is probably too mature for this to
> really be considered.
>
This is actually happening -- gradually these functions are losing the
ability to take both quoted and unquoted arguments. However, it's not a
matter of making them all the same.
is.function() and args() really shouldn't take quoted arguments -- the
argument is an object, not on the name of the object. This is in contrast
to rm(), help(), and find(), where the argument really is the name of the
object. One motivation for persuading people to type ?lm instead of
help(lm) is that it might then be possible to force help() to take quoted
arguments.
There's a similar issue with expressions as arguments. A few functions
such as with(), quote(), substitute(), capture.output() correctly take
unquoted expressions as arguments. Most functions will use only the value
of an unquoted expression. A number of modelling functions, however, use
unquoted expressions without evaluating them, and shouldn't. It's
probably too late to stop this for functions like glm(), but at least new
modelling functions could avoid it. There are notes about this issue at
http://developer.r-project.org/nonstandard-eval.pdf
-thomas
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle
More information about the R-devel
mailing list