a new notion of procedure
when a procedure is evaluated
- we need to know what environment it might modify
- scheme obeys the rule of lexical scoping:
the procedure body is evaluated in the environment
in which the procedure was created
a procedure is a pair
- the code (params and body)
- the environment in which it was created
example
- (define x 100)
results in a new binding in top-level env
- (define (down i) (begin (set! x (- x i)) x))
results in a new binding in the top-level env:
down is associated with the pair
- code: param i, body (begin (set! x (- x 1)) x))
- environment: pointer to top-level environment itself
param ibody (begin (set! x (- x 1)) x))