On May 13, 2010, at 1:16 PM, thmsfuller...@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

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to