[Rd] future plans for missing() in inner functions

Ross Boylan ross at biostat.ucsf.edu
Tue Apr 3 20:04:16 CEST 2007


Currently, if one wants to test if an argument to an outer function is
missing from within an inner function, this works:
> g5 <- function(a) {
+   inner <- function(a) {
+     if (missing(a))
+       "outer arg is missing"
+     else
+       "found outer arg!"
+   }
+   inner(a)
+ }
> g5(3)
[1] "found outer arg!"
> g5()
[1] "outer arg is missing"

While if inner is defined as function() (without arguments) one gets
an error: 'missing' can only be used for arguments.

However, ?missing contains a note that this behavior is subject to
change.

I'm particularly interested in whether the code shown above will
continue to work.  While it does what I want in this case, the
behavior seems a bit surprising since textually the call to inner does
provide an argument.  So it seems possible that might change.

Can anyone provide more insight into how things may change?

Thanks.



More information about the R-devel mailing list