Environment persistence
What does it mean for an environment to be "reachable"? The easiest place to see this is in higher-order functions:
(define (equal-n?? n) (lambda (k) (equal? n k))) (define equal-5? (equal-n?? 5)) The environment in the above example gets "closed" at the time equals-5 is defined. As long as equals-5? is reachable, this environment will persist.
Question
Notice that the above example uses lambda to create a closure, whereas the previous one used let. It turns out that a truly minimal Scheme only needs lambda. How can you rewrite an arbitrary let-expression as a lambda expression?
let, let*
What are the values of the following expressions?
(define x 1) (define y 2) (let ((x 3) (y x)) (+ x y)) (let* ((x 3) (y x)) (+ x y))