pryr:::address
defined as function(x) address2(check_name(substitute(x)), parent.frame())
. If you wrap pryr:::address
in another function, it parent.frame()
will change. For example:.
myfun = function() parent.frame()
myfunwrap = function() { print(environment()); myfun() }
myfun()
myfunwrap()
myfunwrap()
In particular, if I have not lost it somewhere, it pryr::address
works as follows:
ff = inline::cfunction(sig = c(x = "vector", env = "environment"), body = '
Rprintf("%p\\n", findVar(install("x"), env));
return(eval(findVar(install("x"), env), env)); //pryr::address does not evaluate
')
assign("x", "x from GlobalEnv", envir = .GlobalEnv)
ff1 = function(x) ff(x, parent.frame())
ff2 = function(x) ff1(x)
pryr::address(x)
ff(x, .GlobalEnv)
ff1(x)
ff1(x)
ff2(x)
ff2(x)
, "" ( ), - :
add = pryr::address
add(x)