In SICP Chapter 4, the metacircular evaluator is modified by separating the syntax analysis from the execution, making the eval
procedure look like:
(define (eval exp env)
((analyze exp) env))
and the book says that this will save work since analyze
will be called once on an expression, while the execution procedure may be called many times.
My question is, how does this optimization work? It will work for recursive procedure calls, but how about other cases? The evaluator evaluates expressions one after another, eval
will still be called on each expression even if they have identical forms.