Amb amb Evaluator - SICP Comparison Edition" /> 4.3.3   Implementing the <span style="color:green">Amb</span> <span style="color:blue">amb</span> Evaluator - SICP Comparison Edition
Original JavaScript
Original JavaScript
Original JavaScript

[1] We chose to implement the lazy evaluator in section 4.2 as a modification of the ordinary metacircular evaluator of section 4.1.1. In contrast, we will base the amb evaluator on the analyzing evaluator of section 4.1.7, because the execution procedures functions in that evaluator provide a convenient framework for implementing backtracking.
[2] We assume that the evaluator supports let (see exercise 4.31), which we have used in our nondeterministic programs.
[3] With this treatment, amb is no longer a name with proper scoping. To avoid confusion, we must refrain from declaring amb as a name in our nondeterministic programs.
[4] We didn't worry about undoing definitions, since we can assume that internal definitions are scanned out (section 4.1.6). didn't worry about undoing declarations, since we assume that a name can't be used prior to the evaluation of its declaration, so its previous value doesn't matter.
4.3.3   Implementing the Amb amb Evaluator