In SICP 3.2, The Environment Model of Evaluation, is an environment initially the same as its first frame?

StackOverflow https://stackoverflow.com/questions/3761981

  •  04-10-2019
  •  | 
  •  

Question

In The Structure and Interpretation of Computer Programs part 3.2, an "environment" is defined as "a sequence of frames." But as far as I can see, the book doesn't further discuss the difference between an environment and a frame. Also, I suspect the drawings of environments conflates them with frames because books drawings are small and 2-D, and don't readily show time-evolution short of another full drawing.

So would it be correct to think of an environment at creation as being the same as its first frame? And then when any change occurs in the environment (an extant binding changed, a new binding created), the environment adds a new frame to its sequence of frames? If that understanding is NOT correct, then what exactly is the difference between an environment and a frame?

Thanks in advance for any help!

Was it helpful?

Solution

The sequence of frames is the linked list (of frames) pointing 'upwards' towards the global environment. So when an environment is created (for example, in the context of a procedure binding), the 'environment' is a pointer to the frame...which in term points to the enclosing environment (or null, if the global environment).

So ... a qualified 'yes'...it's the first frame in the sense that the rest of the environment is accessible from that first frame.

Does that help?

Cordially, Dak

OTHER TIPS

A lot of times, people use "environment" and "frame" interchangeably. Personally, I've always tried to keep them distinct. I use frame to mean a particular stack and an environment to be all the frames.

I think the initial environment is a sequence of length 1, with just the first frame.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top