[Rd] On the mechanics of function evaluation and argument matching
Ben Bolker
bbolker at gmail.com
Wed Jul 17 19:20:56 CEST 2013
Brian Rowe <rowe <at> muxspace.com> writes:
>
> Thanks for the lead. Given the example in ?missing though,
> wouldn't it be safer to explicitly define a
> default value of NULL:
>
> myplot <- function(x, y=NULL) {
> if(is.null(y)) {
> y <- x
> x <- 1:length(y)
> }
> plot(x, y)
> }
>
[snip]
In my opinion the missing() functionality can indeed be
fragile (for example, I don't know how I can manipulate an
existing call to make an argument be 'missing' when it was
previously 'non-empty') and using an explicit NULL is often
a good idea. This makes the documentation a tiny bit less
wieldy if you have lots of parameters ...
More information about the R-devel
mailing list