Why the $\mathrm{Eval}/\mathrm{Apply}$ cycle is a universal machine
__init__, selfeval + environments model "running code"?"(+ 1 (* 2 3))"" ( + 1 ( * 2 3 ) ) " $\to$ split['(', '+', '1', '(', '*', '2', '3', ')', ')']int/float (e.g., via int(token) / float(token)) or symbol strings; lists parse into Python lists['+', 1, ['*', 2, 3]]['+', ...] $\to$ evaluate pieces, then combine['*', ['+', 1, 2], ['+', 3, 4]] $\to$ $21$eval is a dispatcher: expression type decides the rule$$ \text{eval} : (\text{exp}, E) \to \text{value} $$
applyapply: where environments get extendedeval on a call expression $\to$ needs applyapply on a compound procedure $\to$ needs eval (for the body)if: evaluate the condition, then evaluate only the selected branch['define', 'square', ['lambda', ['x'], ['*', 'x', 'x']]]['square', 5]['square', 5] evaluate to, and which frame will contain x?unless as a derived expression$$ (\texttt{unless}\ c\ a\ b)\;\Rightarrow\;(\texttt{if}\ c\ b\ a) $$
eval['+', 1, ['unless', False, 10, 20]]if be a special form, not an ordinary function?
Powered by SciMigo AI Tutor - https://scimigo.com