Re: [sicp-vsg] Frames
- I wrote earlier:
> This is also a nice way to think about lambda. A lambda creates aI've confused myself a little here. A lambda creates a procedure which
> procedure, which includes a frame. This allows us to save a reference
> to the procedure, and hence the frame, hence the frame persists.
includes a reference to the enclosing environment, i.e. to the frame
created for the procedure invocation in which the lambda is running.
Rule 1: lambda creates a procedure (which is code+environment)
Rule 2: procedure application creates a new frame (binding the args
for this application) which chains to the procedure's environment.
So...a frame is associated with a procedure invocation. It will only
persist once the procedure returns if a reference to the frame is
captured. Which is pretty much iff a lambda is executed in the
procedure body and that lambda value leaves the procedure, either as
the return value or by being set! into another variable.