Exercise 5.32: Using the preserving
mechanism, the compiler will avoid saving and restoring env around the
evaluation of the operator of a combination in the case where the operator is a
symbol. We could also build such optimizations into the evaluator. Indeed,
the explicit-control evaluator of 5.4 already performs a similar
optimization, by treating combinations with no operands as a special case.
Extend the explicit-control evaluator to recognize as a separate class of
expressions combinations whose operator is a symbol, and to take advantage of
this fact in evaluating such expressions.
Alyssa P. Hacker suggests that by extending the evaluator to recognize more and
more special cases we could incorporate all the compiler’s optimizations, and
that this would eliminate the advantage of compilation altogether. What do you
think of this idea?
练习 5.32:借助 preserving 机制,当组合式的运算符是符号时,编译器可以避免在对其求值前后保存和恢复 env。我们也可以将这类优化内置到求值器中。实际上,5.4 节的显式控制求值器已经通过将无运算对象的组合式作为特殊情况来处理,执行了类似的优化。
扩展显式控制求值器,使其将运算符为符号的组合式识别为一类独立表达式,并在对此类表达式求值时加以利用。
Alyssa P. Hacker 认为,通过不断扩展求值器以识别越来越多的特殊情况,可以将编译器的所有优化都纳入求值器,从而彻底消除编译的优势。你对这一观点有何看法?