From ross at biostat.ucsf.edu  Tue Apr  3 20:04:16 2007
From: ross at biostat.ucsf.edu (Ross Boylan)
Date: Tue, 3 Apr 2007 11:04:16 -0700
Subject: [Rd] future plans for missing() in inner functions
Message-ID: <20070403180416.GA25978@wheat.betterworld.us>

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.



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