limist
limist

Reputation: 1308

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

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!

Upvotes: 5

Views: 1154

Answers (3)

Catherine Hwang
Catherine Hwang

Reputation: 1030

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.

Upvotes: 2

Dak
Dak

Reputation: 116

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

Upvotes: 2

newacct
newacct

Reputation: 122439

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

Upvotes: 0

Related Questions