tags:

views:

90

answers:

3

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!

A: 

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

newacct
+1  A: 

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

Dak
That helps, thanks - so ultimately, an environment is a pointer to a sequence of frames, and initially, that sequence has just one frame. But then what about the global environment? Perhaps it's further on in the book, but if the global env is also just a pointer to a sequence of frames, where's the "global procedure" that points to the global sequence-of-frames? This is like the first-cause dilemma... :)
limist
A: 

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.

Kevin Hwang