Professional Documents
Culture Documents
ENVIRONMENTS
In the presence of assignment, a variable can no longer be considered
to be merely a name for a value. Rather, a variable must somehow de
signate a ``place in which values can be stored. These places will be
maintainted in structures called environments.
An environment is a sequence of frames.
Frames:
1. Each frame is a table (possibly empty) of bindings, which associate variable na
mes with their corresponding values
2. Each frame also has a pointer to its enclosing environment (except the global
frame)
[THE APPLICATION]
. To apply a procedure to arguments, create a new environment contai
ning a frame that binds the parameters to the value of the arguments.
The enclosing environment of this frame is the environment specified
by the procedure.
PROCEDURE good-enough?s
Environment = E1 : (FB, FA)
(define ...)
1. procedure object
global env
2. ``define make-withdraw
procedure object
(define..)
1. (make-withdraw
100) : E1
(formal
parameter=100)
frame make-withdraw
(global env)
procedure
object
2. ``define W1
procedure object
(W1 50)
1. (W1 50) :
(amount=50) frame
W1 (E1)
50
(set! ..)
1. ``set! E1
(define..)