[R] Question about looking up names

Thomas Lumley tlumley at u.washington.edu
Wed Jun 4 01:30:44 CEST 2003


On 3 Jun 2003, Ross Boylan wrote:

> I think I now understand how R looks up names.  Could anyone tell me if
> I have this right?
>
> First it looks up the nested environments created by lexical scoping.
> Then, if it gets to the top (.GlobalEnv) it also looks through the list
> of things that have been "attach"ed.
>
> It never looks in the call stack unless you explicitly ask it to, or
> mess with the environment frames.
>
> The reason I ask is that it's not entirely clear to me from the "R
> Language Definition" how these 3 search spaces (environments/lexical
> scoping; call stack/dynamic scoping; attach/search list) are related.
> For example the discussion of 3.5.3 ("the call stack") observes that
> dynamic scoping "contradicts the default scoping rules in R".  I spent
> some time trying to figure out how it could do both, before deciding it
> doesn't.  I suppose the implicit corollary of the contradiction referred
> to in 3.5.3--"so we don't do that and you must intervene to achieve
> dynamic scoping"--was obvious to the authors.  It just wasn't obvious to
> me.  Since I'm still not sure, I thought I'd check.
>

Yes.


	-thomas




More information about the R-help mailing list