Roger D. Peng
2009-Mar-16 00:45 UTC
[Rd] Using and 'eval' and environments with active bindings
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/
luke at stat.uiowa.edu
2009-Mar-16 15:37 UTC
[Rd] Using and 'eval' and environments with active bindings
Thanks for the report. I meant to have R_isMissing always return FALSE for active binding but had it returning TRUE intead. Fixed now in R-devel. luke On Sun, 15 Mar 2009, Roger D. Peng wrote:> 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 >-- Luke Tierney Chair, Statistics and Actuarial Science Ralph E. Wareham Professor of Mathematical Sciences University of Iowa Phone: 319-335-3386 Department of Statistics and Fax: 319-335-3017 Actuarial Science 241 Schaeffer Hall email: luke at stat.uiowa.edu Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu