[Rd] Using and 'eval' and environments with active bindings

Roger D. Peng rpeng at jhsph.edu
Mon Mar 16 01:45:56 CET 2009


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/



More information about the R-devel mailing list