[Rd] sys.function(0)
Mick Jordan
mick.jordan at oracle.com
Sun Mar 27 22:05:08 CEST 2016
As I understand
https://stat.ethz.ch/R-manual/R-devel/library/base/html/sys.parent.html
sys.function(n) returns the function associated with stack frame n.
Since frame 0 is defined as .GlobalEnv which is not associated with a
function, I would expect this to always return NULL. However, it does not:
> sys.function()
NULL
> f <- function(x) sys.function(x)
> f(0)
function(x) sys.function(x)
> f(1)
function(x) sys.function(x)
> f(2)
Error in sys.function(x) : not that many frames on the stack
Why the different behavior when sys.function(0) is called inside another
function?
Mick Jordan
[[alternative HTML version deleted]]
More information about the R-devel
mailing list