[Rd] What functions are called internally in R to resolve what variable is referred?
Simon Urbanek
simon.urbanek at r-project.org
Thu May 13 20:22:58 CEST 2010
On May 13, 2010, at 1:16 PM, thmsfuller066 at gmail.com wrote:
> Hello All,
>
> If I refer to a variable 'x', 'x' will be searched in the current
> frame or the parent frame, or the parent of the parent frame, etc.,
> until it is found (or not found at all)? Could you please show me what
> code in R source that handles this? Is it in the C code or the R code?
>
At R level it is done automatically during evaluation (but you can so something similar using get() function in R). Internally (in C), findVar(symbol, env) in src/main/envir.c does the job by using findVarInFrame3() recursively for parent environments. There is slight exception if you use x() since that does a search with the restriction that x must be a function and thus uses findFun() instead.
Cheers,
Simon
More information about the R-devel
mailing list