[Rd] sys.function(0)

Mick Jordan mick.jordan at oracle.com
Sun Mar 27 22:05:08 CEST 2016

As I understand 
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()
 > 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 

Mick Jordan

	[[alternative HTML version deleted]]

More information about the R-devel mailing list