R-alpha: missing() bug

Ross Ihaka (ihaka@stat.auckland.ac.nz)
Wed, 11 Sep 1996 13:58:30 +1200


Date: Wed, 11 Sep 1996 13:58:30 +1200
From: Ross Ihaka <ihaka@stat.auckland.ac.nz>
Message-Id: <199609110158.NAA21737@stat.auckland.ac.nz>
To: r-testers@stat.math.ethz.ch
Subject: R-alpha: missing() bug
In-Reply-To: <Pine.SUN.3.91.960910134805.27995B-100000@chekov>
	<Pine.SUN.3.91.960910134805.27995B-100000@chekov>

Thomas Lumley writes:
 > 
 > In 0.11 missing() does not work correctly in nested functions:
 > eg:
 > 
 > > a<-function (x) {
 > 	missing(x)
 > }
 > > b<-function (x) a(x)
 > 
 > > a()
 > [1] TRUE
 > > b()
 > [1] FALSE
 > 
 > This is particularly a problem with methods, which don't usually check 
 > the arguments they pass down to NextMethod()
 
This is a nasty one!  The problem is that we have a slightly different
"missing" because of our different scoping rules.

We have to make the following thing work:

	f <- function(x) {
		g <- function(y)
			missing(x)
		g()
	}

Because the missing(x) occurs within the body of a function which has
x as a formal argument it should really test the missingness of that
argument.

This means that we are already recursing up through possible nested
function declarations, and now we also have to consider recursing up
through nested function calls as well.  Hmmm.
	Ross
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
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
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-