[R] terminology for frames and environments

Peter Dalgaard p.dalgaard at biostat.ku.dk
Mon Jun 14 09:42:29 CEST 2004


"Gabor Grothendieck" <ggrothendieck at myway.com> writes:

> In ?exists it says:
> 
> inherits: should the enclosing frames of the environment be searched?
> 
> I believe what it is saying is that if inherits is TRUE and it fails
> to find the variable it will look in the parent environment and
> the parent of the parent, etc. (as opposed to looking in the calling
> frame next and the caller of the caller, etc.)
> 
> Now I thought that standard terminology in R was:
> 
> 1. enclosing environment or parent environment if one wanted to
> refer to the parent relative to the parent/child hierarchy 
> of environments
> 
> or
> 
> 2. calling frame or parent frame if one
> wanted to refer to a parent relative to the environments
> corresponding to the functions in the stack 
> of currently outstanding function calls
> 
> but here we seem to be referring to a parent frame as a #1. 
> 
> Could someone please clarify what standard terminology is?

Not sure there is one... 

We have been approaching consensus on a couple of occasions, but
(obviously) not been too good at enforcing it. I think the consensus
is that a "frame" is a set of variable bindings (implemented as a
hashed list), an environment is a frame plus an enclosing environment,
i.e. a linked list of frames, terminated by NULL. It is occasionally
necessary to refer to the individual frames as opposed to the whole
list, which is exactly the point of the inherits argument.

Notice that exists() talks about "enclosing" which is only ever used
in sense #1 above. "parent" is used in both senses (which is a bit
unfortunate -- not quite sure whether we have decided to get rid of
parent.env() eventually).

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907




More information about the R-help mailing list