title: Difference between Metacircular Evaluator and the Analyzing (Metacircular) Evaluator
body: <p>In <a href="https://mitpress.mit.edu/sicp/full-text/book/book-Z-H-26.html#%_sec_4.1" rel="nofollow">section 4.1 of the Structure and Interpretation of Computer Programs</a> there are two evaluators introduced, being the metacircular evaluator and the analysing metacircular evaluator.</p>
  
  <p>The full metacircular evaluator can be found here:
  <a href="https://mitpress.mit.edu/sicp/code/ch4.scm" rel="nofollow">https://mitpress.mit.edu/sicp/code/ch4.scm</a></p>
  
  <p>And the full metacircular evaluator with analysis can be found here:
  <a href="https://mitpress.mit.edu/sicp/code/ch4-analyzingmceval.scm" rel="nofollow">https://mitpress.mit.edu/sicp/code/ch4-analyzingmceval.scm</a></p>
  
  <p>Now, the difference between the two is that the analysing evaluator <code>eval</code> has analysis methods for analysing the expression.</p>
  
  <pre><code>(define (eval exp env)
    ((analyze exp) env))
  
  (define (analyze exp)
    (cond ((self-evaluating? exp) 
           (analyze-self-evaluating exp))
          ((quoted? exp) (analyze-quoted exp))
          (...)
  </code></pre>
  
  <p>Where the analysis procedure does for example this:</p>
  
  <pre><code>(define (analyze-self-evaluating exp)
    (lambda (env) exp))
  </code></pre>
  
  <p>or this:</p>
  
  <pre><code>(define (analyze-quoted exp)
    (let ((qval (text-of-quotation exp)))
      (lambda (env) qval)))
  </code></pre>
  
  <p>Whereas the metacircular evaluator <code>eval</code> does this:</p>
  
  <pre><code>(define (eval exp env)
    (cond ((self-evaluating? exp) exp)
    (...)
  
  (define (text-of-quotation exp) (cadr exp))
  </code></pre>
  
  <p>What I expected the analysing evaluator to do is caching previously analyzed results somewhere in the environment, but I do not see this. I don't see what the analysing evaluator exactly does. </p>
  
  <p>So, what does the analyzing evaluator exactly do and why does it speed up the evaluator by a fair bit?</p>