Exercise 4.28. Eval uses actual-value rather than eval to evaluate the operator before passing it to apply, in order to force the value of the operator. Give an example that demonstrates the need for this forcing.
如果 eval 中的 application 的处理方式变为了
((application? exp)
(apply1 (eval (operator exp) env)
(operands exp)
env))
将会导致使用高阶函数的过程无法得到结果。
设想,我们有过程
(define (foo f x) (f x))
然后调用
(foo (lambda (x) x) 1)
在没有使用 lazy-evaluation 的过程中,这个调用会得到 1。但是在 lazy-evaluation 中,所有的参数都将变成 trunks。这就意味着,如果 application 的处理只使用的 eval 而不使用 actual-value 的话,一旦把过程作为参数传递到过程中,我们将得到下面的结果:
((trunks (lambda (x) x)) (trunks 1))
所以得到结果:
;;; L-Eval input:
(foo (lambda (x) x) 1)
; apply1 "Unknown procedure type -- APPLY" (thunk (lambda ... x) (...))