Jeremy Siek пре 3 година
родитељ
комит
e8f77bdc5b
2 измењених фајлова са 25 додато и 14 уклоњено
  1. 22 12
      book.tex
  2. 3 2
      defs.tex

+ 22 - 12
book.tex

@@ -7630,17 +7630,17 @@ but the \code{if} expression is not.  All three sub-expressions of an
 \code{if} are allowed to be complex expressions but the operands of
 \code{not} and the comparisons must be atomic.
 %
-\python{We add a new language form, the \code{Let} expression, to aid
+\python{We add a new language form, the \code{Begin} expression, to aid
   in the translation of \code{if} expressions. When we recursively
   process the two branches of the \code{if}, we generate temporary
   variables and their initializing expressions. However, these
   expressions may contain side effects and should only be executed
   when the condition of the \code{if} is true (for the ``then''
-  branch) or false (for the ``else'' branch). The \code{Let} provides
+  branch) or false (for the ``else'' branch). The \code{Begin} provides
   a way to initialize the temporary variables within the two branches
-  of the \code{if} expression.  In general, the $\LET{x}{e_1}{e_2}$
-  form assigns the result of $e_1$ to the variable $x$, and then
-  evaluates $e_2$, which may reference $x$.}
+  of the \code{if} expression.  In general, the $\BEGIN{ss}{e}$
+  form execute the statements $ss$ and then returns the result of
+  expression $e$.}
 
 Add cases for Boolean constants, \python{comparisons,} and \code{if}
 expressions to the \code{rco\_exp} and \code{rco\_atom} functions
@@ -7949,7 +7949,7 @@ def explicate_effect(e, cont, basic_blocks):
             ...
         case Call(func, args):
             ...
-        case Let(var, rhs, body):
+        case Begin(body, result):
             ...
         case _:
             ...
@@ -7958,7 +7958,7 @@ def explicate_assign(rhs, lhs, cont, basic_blocks):
     match rhs:
         case IfExp(test, body, orelse):
             ...
-        case Let(var, rhs, body):
+        case Begin(body, result):
             ...
         case _:
             return [Assign([lhs], rhs)] + cont
@@ -7977,7 +7977,7 @@ def explicate_pred(cnd, thn, els, basic_blocks):
             ...
         case IfExp(test, body, orelse):
             ...
-        case Let(var, rhs, body):
+        case Begin(body, result):
             ...
         case _:
             return [If(Compare(cnd, [Eq()], [Constant(False)]),
@@ -12531,6 +12531,7 @@ inner-product of two arrays (Figure~\ref{fig:inner-product}).
 \fbox{
   \begin{minipage}{0.96\textwidth}
     \small
+{\if\edition\racketEd    
 \[
 \begin{array}{lcl}
   \Type &::=& \ldots \MID \LP \key{Vectorof}~\Type \RP \\
@@ -12556,6 +12557,10 @@ inner-product of two arrays (Figure~\ref{fig:inner-product}).
   \LangArray{} &::=& \gray{\Def\ldots \; \Exp}
 \end{array}
 \]
+\fi}
+{\if\edition\pythonEd    
+UNDER CONSTRUCTION
+\fi}
 \end{minipage}
 }
 \caption{The concrete syntax of \LangArray{}, extending \LangLoop{} (Figure~\ref{fig:Lwhile-concrete-syntax}).}
@@ -15680,9 +15685,9 @@ to avoid code duplication.
 \begin{lstlisting}
 Call(|$e$|, [|$e_1, \ldots, e_n$|])
 |$\Rightarrow$|
-Let(|$\itm{tmp}$|, |$e'$|,
-  Call(Subscript(Name(|$\itm{tmp}$|), Constant(0)),
-       [|$\itm{tmp}$|, |$e'_1, \ldots, e'_n$|]))
+Begin([Assign([|$\itm{tmp}$|], |$e'$|)],
+      Call(Subscript(Name(|$\itm{tmp}$|), Constant(0)),
+           [|$\itm{tmp}$|, |$e'_1, \ldots, e'_n$|]))
 \end{lstlisting}
 \fi}
 \end{minipage}
@@ -16254,7 +16259,8 @@ True[0]
 \begin{figure}[tp]
 \centering
 \fbox{
-\begin{minipage}{0.97\textwidth}
+  \begin{minipage}{0.97\textwidth}
+{\if\edition\racketEd    
 \[
 \begin{array}{rcl}
   \itm{cmp} &::= & \key{eq?} \MID \key{<} \MID \key{<=} \MID \key{>} \MID \key{>=} \\
@@ -16277,6 +16283,10 @@ True[0]
 \LangDynM{}  &::=& \Def\ldots\; \Exp
 \end{array}
 \]
+\fi}
+{\if\edition\pythonEd
+  UNDER CONSTRUCTION
+\fi}
 \end{minipage}
 }
 \caption{Syntax of \LangDyn{}, an untyped language (a subset of \racket{Racket}\python{Python}).}

+ 3 - 2
defs.tex

@@ -165,8 +165,9 @@
 \fi
 
 \if\edition\pythonEd
-\newcommand{\LET}[3]{\key{Let}\LP #1 \key{,} #2 \key{,} #3 \RP}
-\newcommand{\CLET}[3]{\key{let}~#1~\key{=}~#2~\key{in}~#3}
+%% Use BEGIN instead of LET -Jeremy
+%% \newcommand{\LET}[3]{\key{Let}\LP #1 \key{,} #2 \key{,} #3 \RP}
+%% \newcommand{\CLET}[3]{\key{let}~#1~\key{=}~#2~\key{in}~#3}
 \newcommand{\INT}[1]{{\key{Constant}\LP#1\RP}}
 \newcommand{\READOP}{{\key{input\_int}}}
 \newcommand{\READ}{{\key{Call(Name('input\_int'),[])}}}