令人感到担心的是,这种情况非常复杂。
我想谈谈一个论点,但也知道应当对其加以评价的环境。 与此类似:
make.promise = function(x = print(b), b = 7) {
expr = substitute(x)
env = parent.frame()
function() {
eval(expr, env)
}
}
p1 = (
function() {
a = 2
make.promise(print(a))
}
)()
p2 = make.promise()
The problem is, if no argument is supplied for x
, its environment becomes the local environment of make.promise()
, and I don t know how to detect that. Is there a function other than substitute
I could use that also captures the environment?