Displaying 3 results from an estimated 3 matches for "r_syscall".
Did you mean:
__syscall
2016 Mar 27
2
sys.function(0)
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)
2016 Mar 27
0
sys.function(0)
...0) is always the global envir. It is pretty clear from the underlying C code that the three functions treat their argument differently:
R_sysframe has
if (n == 0)
return(R_GlobalEnv);
if (n > 0)
n = framedepth(cptr) - n;
else
n = -n;
whereas the other two (R_syscall and R_sysfunction) omit the special treatment for n==0. Without this, n==0, comes out unchanged from the if-construct, indicating that one should go 0 frames up the stack (same as n==framedepth(cptr)).
Obviously, it won't work to document the "which" argument identically for all thre...
2016 Mar 27
1
sys.function(0)
...erlying C code that the three functions treat their argument differently:
>
> R_sysframe has
>
> if (n == 0)
> return(R_GlobalEnv);
>
> if (n > 0)
> n = framedepth(cptr) - n;
> else
> n = -n;
>
> whereas the other two (R_syscall and R_sysfunction) omit the special treatment for n==0. Without this, n==0, comes out unchanged from the if-construct, indicating that one should go 0 frames up the stack (same as n==framedepth(cptr)).
>
> Obviously, it won't work to document the "which" argument identically for...