* The Explicit-Control Evaluator this is how to implement /scheme itself/ on bare metal. cool as hell. the register machine contains a stack and seven registers: - exp - env - val - continue - proc - argl - unev ** 5.4.1 the core of the explicit-control evaluator the central element of the evaluator is the sequence of instructions beginning at eval-dispatch after eval, the controller goes the the entry point stored in continue and the val register holds the value of the expression eval-dispatch is a case analysis on the syntactic type of expression to be evaluated ** 5.4.2 sequence evaluation and tail recursion this handles sequences of expressions in procedure bodies or in begin expressions. TAIL RECURSION a procedure such as #+BEGIN_SRC scheme (define (sqrt-iter guess x) (if (good-enuff? guess x) guess (sqrt-iter (improve guess x) x))) #+END_SRC is syntactically recursive but operationally iterative. but only with tail recursion. - tail-recursive evaluator :: an evaluator that can execute a procedure such as sqrt-iter without requiring increasing storage as the procedure continues to call itself implementing tail recursion is a simple, universal, and profound thing ** 5.4.3 conditionals, assignment, and definitions special forms are handles by selectively evaluating fragments of the expression. assignments and definitions are handled similarly with set-variable-value! ** 5.4.4 running the evaluator with the implementation of the evaluator we have come to the conclusion of a development started back in chapter 1, exploring more precise models of evaluation: - substitution - relatively informal - environment - deal with state and change - metacircular evaluator - using scheme itself - register machines - a close look at the mechanisms for storage management, argument passing, and control each layer raised issues and ambiguities that were not apparent at the previous levels. now we can implement and monitor the performance of our machine at its basest levels. the simulation will of course be slow (it's a simulation running in a simulation running in a simulation...) but we can do cool things like monitor and evaluate its performance.