Exercise 4.17

I’m not drawing any more environment diagrams.

If the evaluator treats the definitions sequentially, the internal definitions will be added to the current frame (at the time the defined procedure is called) during evaluation.
If the evaluator scans out the definitions as described in Exercise 4.16, an extra frame is created because we transform the definitions into a let expression, which in turn is transformed into a lambda expression, which creates a new frame linked to the environment of the outer definition. This is safe because the new frame isolates the new definitions from the outer environment.

To do this without scanning out the internal defintions a rule would have to be enforced that internal definitions are created before the remainder of the body of the outer definition. I actually did enforce this rule in Exercise 4.16 because that already the behaviour of Racket.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s