environment model explanation
to make sense of down2, carefully evaluate its definition
- let is short for lambda
- so we evaluate in the top-level environment
((lambda (x) )) (lambda (i) (set! x (- x i)) x)) ) 100)
- create a fresh frame for the argument x
- the inner lambda evaluates to itself, since it’s not applied here
- resulting value is bound to down2 in top-level env
-
-
-
-
-
-
-
-
-
-
- now when down2 is applied, evaluation of body is in the environment EB
param ibody (begin (set! x (- x 1)) x))
param ibody (begin (set! x (- x 1)) x))