We have procedure:
1 2 3 4 (define (solve f y0 dt) (define y (integral (delay dy) y0 dt)) (define dy (stream-map f y)) y)
As shown in this exercise, this will get converted to:
1 2 3 4 5 6 7 (define (solve f y0 dt) (let ((y '*unassigned*) (dy '*unassigned*)) (let ((a (integral (delay dy)) y0 dt) (b (stream-map f y))) (set! y a) (set! dy b))))
delay is implemented as special form in our evaluator such that it behaves as described in chapter-3, i.e. arguments to
delay are not evaluated until it is accessed.
b we require
dy to be correctly defined because there is no
(delay y) in
b expression. Thus it won’t work.
However, it will work with the way we implemented transformation described in the text because now before evaluating
y will be already defined.