|
@@ -22,7 +22,7 @@
|
|
|
|
|
|
\def\racketEd{0}
|
|
|
\def\pythonEd{1}
|
|
|
-\def\edition{0}
|
|
|
+\def\edition{1}
|
|
|
|
|
|
% material that is specific to the Racket edition of the book
|
|
|
\newcommand{\racket}[1]{{\if\edition\racketEd{#1}\fi}}
|
|
@@ -1815,8 +1815,10 @@ 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{}
|
|
|
+be for the interpreter of \LangVar{} to handle the
|
|
|
+\racket{cases for variables and \code{let}}
|
|
|
+\python{case for variables}
|
|
|
+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}.)
|
|
@@ -1986,8 +1988,11 @@ y = 10
|
|
|
print(-y)
|
|
|
\end{lstlisting}
|
|
|
\fi}
|
|
|
-\noindent We can invoke the \code{interp\_exp} method for \LangVar{} on this
|
|
|
-expression, call it \code{e0}, by creating an object of the \LangVar{} class
|
|
|
+\noindent We can invoke the \code{interp\_exp} method for \LangVar{}
|
|
|
+\racket{on this expression,}
|
|
|
+\python{on the \code{-y} expression,}
|
|
|
+%
|
|
|
+call it \code{e0}, by creating an object of the \LangVar{} class
|
|
|
and calling the \code{interp\_exp} method.
|
|
|
{\if\edition\racketEd
|
|
|
\begin{lstlisting}
|
|
@@ -2058,7 +2063,7 @@ interpreter for \LangVar{} adds two new \key{match} cases for
|
|
|
variables and \racket{\key{let}}\python{assignment}. For
|
|
|
\racket{\key{let}}\python{assignment} we need a way to communicate the
|
|
|
value bound to a variable to all the uses of the variable. To
|
|
|
-accomplish this, we maintain a mapping from variables to values,
|
|
|
+accomplish this, we maintain a mapping from variables to values
|
|
|
called an \emph{environment}\index{subject}{environment}.
|
|
|
%
|
|
|
We use%
|