From mick.jordan at oracle.com  Sun Mar 27 22:05:08 2016
From: mick.jordan at oracle.com (Mick Jordan)
Date: Sun, 27 Mar 2016 13:05:08 -0700
Subject: [Rd] sys.function(0)
Message-ID: <56F83CF4.3050900@oracle.com>

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]]



[Rd] sys.function(0)
Mick Jordan