The lexical address of a variable in a program depends on where one is in the code. One way for the compiler to produce code that uses lexical addressing is to maintain a data structure called a compile-time environment . The compile-time environment is a list of frames, each containing a list of variables. The compile-time environment becomes an additional argument to compile and is passed along to each code generator. Exercises through describe how to complete this sketch of the lexical-addressing strategy in order to incorporate lexical lookup into the compiler.
Exercise describes another use for the compile-time environment.
Modify the compiler to maintain the compile-time environment as described above. Section and exercise showed how to modify the metacircular interpreter to accomplish this by scanning out internal definitions. In this section we have focused on the use of the compile-time environment to produce lexical addresses. But there are other uses for compile-time environments. For instance, in exercise we increased the efficiency of compiled code by open-coding primitive procedures.