Page:AIM-453.djvu/31

From Wikisource
Jump to navigation Jump to search
There was a problem when proofreading this page.
Steele and Sussman
29
The Art of the Interpreter

during any one processing cycle of EVAL/APPLY, PROCEDURES remains constant. We can thus choose to associate the top level environment with a top-level procedure at a time earlier than invocation time in APPLY. We also note that LOOKUP1 will have its hands on the top-level environment anyway just before it locates the definition of a top-level procedure. Exploiting this idea yields an alternate solution. {Note LABELS}

In the new driver (see Figure 10) loop we no longer use BIND to augment the top-level environment whenever a new definition is made. We instead have all of the top-level definitions in one frame of the environment. When a new definition is to be made we extract the list of names and the list of values for the old definitions from the old environment and make a new top-level environment with the lists of names and values separately augmented.

Instead of creating &PROCEDURE-objects, this driver loop creates &LABELED-objects, which have the same format except that they contain no environment. A &LABELED-object is purely internal and can never be seen by a user program. When LOOKUP1 encounters such an object as the value of a variable, it immediately creates the corresponding &PROCEDURE-object, using the environment at hand, which turns out to be the top-level environment.