From rpeng at jhsph.edu  Mon Mar 16 01:45:56 2009
From: rpeng at jhsph.edu (Roger D. Peng)
Date: Sun, 15 Mar 2009 20:45:56 -0400
Subject: [Rd] Using and 'eval' and environments with active bindings
Message-ID: <66f3bd910903151745k42407ec4xb4771fa3e7ef4ac2@mail.gmail.com>

The following code produces an error in current R-devel

f <- function(value) {
        if(!missing(value))
                100
        else
                2
}
e <- new.env()
makeActiveBinding("x", f, e)
eval(substitute(list(x)), e)

The error, after calling 'eval' is

Error in eval(expr, envir, enclos) :
  element 1 is empty;
   the part of the args list of 'list' being evaluated was:
   (x)


It has something to do with the change in R_isMissing in revision
r48118 but I'm not quite knowledgeable enough to understand what the
problem is. In R 2.8.1 the result was simply


> eval(substitute(list(x)), e)
[[1]]
[1] 2

I can't say I know what the output should be but I'd like some
clarification on whether this is a bug.

Thanks,
-roger
-- 
Roger D. Peng  |  http://www.biostat.jhsph.edu/~rpeng/



[Rd] Using and 'eval' and environments with active bindings
Roger D. Peng