modifying environments
an environment is
- a mutable data structure!
special forms
- (define v e)
evaluate e to some value E
add a fresh binding that associates the variable v with the value E
- (set! v e)
evaluate e to some value E
change v’s binding to that v is now associated with E
- notes
a redefinition is actually a set!
(set! v e) fails if v is not bound
example
(define x 100)
x ==> 100
(set! x 99)
x ==> 99