|
@@ -22,7 +22,7 @@
|
|
|
|
|
|
\def\racketEd{0}
|
|
|
\def\pythonEd{1}
|
|
|
-\def\edition{1}
|
|
|
+\def\edition{0}
|
|
|
|
|
|
% material that is specific to the Racket edition of the book
|
|
|
\newcommand{\racket}[1]{{\if\edition\racketEd{#1}\fi}}
|
|
@@ -1809,17 +1809,17 @@ $52$ then $10$, the following produces $42$ (not $-42$).
|
|
|
\subsection{Extensible Interpreters via Method Overriding}
|
|
|
\label{sec:extensible-interp}
|
|
|
|
|
|
-To prepare for discussing the interpreter for \LangVar{}, we explain
|
|
|
-why we to implement the interpreter using object-oriented programming,
|
|
|
-that is, as a collection of methods inside of a class. Throughout this
|
|
|
-book we define many interpreters, one for each of the languages that
|
|
|
-we study. Because each language builds on the prior one, there is a
|
|
|
-lot of commonality between these interpreters. We want to write down
|
|
|
-the common parts just once instead of many times. A naive approach
|
|
|
-would be for the interpreter of \LangVar{} to handle the cases for
|
|
|
-variables and \code{let} but dispatch to \LangInt{} for the rest of
|
|
|
-the cases. The following code sketches this idea. (We explain the
|
|
|
-\code{env} parameter soon, in Section~\ref{sec:interp-Lvar}.)
|
|
|
+To prepare for discussing the interpreter of \LangVar{}, we explain
|
|
|
+why we implement it in an object-oriented style. Throughout this book
|
|
|
+we define many interpreters, one for each of language that we
|
|
|
+study. Because each language builds on the prior one, there is a lot
|
|
|
+of commonality between these interpreters. We want to write down the
|
|
|
+common parts just once instead of many times. A naive approach would
|
|
|
+be for the interpreter of \LangVar{} to handle the cases for variables
|
|
|
+and \racket{\code{let}}\python{assignment} but dispatch to \LangInt{}
|
|
|
+for the rest of the cases. The following code sketches this idea. (We
|
|
|
+explain the \code{env} parameter soon, in
|
|
|
+Section~\ref{sec:interp-Lvar}.)
|
|
|
|
|
|
\begin{center}
|
|
|
{\if\edition\racketEd
|
|
@@ -2566,7 +2566,7 @@ and x86 assembly? Here are some of the most important ones:
|
|
|
integer constants, registers, and memory locations.
|
|
|
|
|
|
{\if\edition\racketEd
|
|
|
-\item[(c)] The order of execution in x86 is explicit in the syntax: a
|
|
|
+\item The order of execution in x86 is explicit in the syntax: a
|
|
|
sequence of instructions and jumps to labeled positions, whereas in
|
|
|
\LangVar{} the order of evaluation is a left-to-right depth-first
|
|
|
traversal of the abstract syntax tree.
|
|
@@ -2701,7 +2701,7 @@ outstanding problems.
|
|
|
{\if\edition\pythonEd
|
|
|
\begin{tikzpicture}[baseline=(current bounding box.center)]
|
|
|
\node (Lvar) at (0,2) {\large \LangVar{}};
|
|
|
-\node (Lvar-2) at (3,2) {\large \LangVar{}};
|
|
|
+\node (Lvar-2) at (3,2) {\large \LangVarANF{}};
|
|
|
\node (x86-1) at (3,0) {\large \LangXVar{}};
|
|
|
\node (x86-2) at (6,0) {\large \LangXVar{}};
|
|
|
\node (x86-3) at (9,0) {\large \LangXInt{}};
|