I am having trouble with drake issue 35, and I have reproduced a minimal version of the bug for this SO post. Briefly, I want eval(parse())
to work with nested functions, nontrivial closures, and a custom environment. I will consider the problem solved if eval(parse(text = "f(1:10)"), envir = e)
below returns 2:11
with no errors or warnings.
e = new.env(parent = globalenv())
e$f = Vectorize(function(x) g(x), "x")
e$g = function(x) x + 1
eval(parse(text = "f(1:10)"), envir = e)
Error in (function (x) : could not find function "g"
environment(e$f) = environment(e$g) = e
eval(parse(text = "f(1:10)"), envir = e)
Error in match(x, table, nomatch = 0L) : object 'vectorize.args' not found
EDIT
In the real world, f
and g
are user-defined, so I should keep the bodies of these functions as-is.