Jeremy Siek 3 år sedan
förälder
incheckning
e8f77bdc5b
2 ändrade filer med 25 tillägg och 14 borttagningar
  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{if} are allowed to be complex expressions but the operands of
 \code{not} and the comparisons must be atomic.
 \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
   in the translation of \code{if} expressions. When we recursively
   process the two branches of the \code{if}, we generate temporary
   process the two branches of the \code{if}, we generate temporary
   variables and their initializing expressions. However, these
   variables and their initializing expressions. However, these
   expressions may contain side effects and should only be executed
   expressions may contain side effects and should only be executed
   when the condition of the \code{if} is true (for the ``then''
   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
   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}
 Add cases for Boolean constants, \python{comparisons,} and \code{if}
 expressions to the \code{rco\_exp} and \code{rco\_atom} functions
 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 Call(func, args):
             ...
             ...
-        case Let(var, rhs, body):
+        case Begin(body, result):
             ...
             ...
         case _:
         case _:
             ...
             ...
@@ -7958,7 +7958,7 @@ def explicate_assign(rhs, lhs, cont, basic_blocks):
     match rhs:
     match rhs:
         case IfExp(test, body, orelse):
         case IfExp(test, body, orelse):
             ...
             ...
-        case Let(var, rhs, body):
+        case Begin(body, result):
             ...
             ...
         case _:
         case _:
             return [Assign([lhs], rhs)] + cont
             return [Assign([lhs], rhs)] + cont
@@ -7977,7 +7977,7 @@ def explicate_pred(cnd, thn, els, basic_blocks):
             ...
             ...
         case IfExp(test, body, orelse):
         case IfExp(test, body, orelse):
             ...
             ...
-        case Let(var, rhs, body):
+        case Begin(body, result):
             ...
             ...
         case _:
         case _:
             return [If(Compare(cnd, [Eq()], [Constant(False)]),
             return [If(Compare(cnd, [Eq()], [Constant(False)]),
@@ -12531,6 +12531,7 @@ inner-product of two arrays (Figure~\ref{fig:inner-product}).
 \fbox{
 \fbox{
   \begin{minipage}{0.96\textwidth}
   \begin{minipage}{0.96\textwidth}
     \small
     \small
+{\if\edition\racketEd    
 \[
 \[
 \begin{array}{lcl}
 \begin{array}{lcl}
   \Type &::=& \ldots \MID \LP \key{Vectorof}~\Type \RP \\
   \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}
   \LangArray{} &::=& \gray{\Def\ldots \; \Exp}
 \end{array}
 \end{array}
 \]
 \]
+\fi}
+{\if\edition\pythonEd    
+UNDER CONSTRUCTION
+\fi}
 \end{minipage}
 \end{minipage}
 }
 }
 \caption{The concrete syntax of \LangArray{}, extending \LangLoop{} (Figure~\ref{fig:Lwhile-concrete-syntax}).}
 \caption{The concrete syntax of \LangArray{}, extending \LangLoop{} (Figure~\ref{fig:Lwhile-concrete-syntax}).}
@@ -15680,9 +15685,9 @@ to avoid code duplication.
 \begin{lstlisting}
 \begin{lstlisting}
 Call(|$e$|, [|$e_1, \ldots, e_n$|])
 Call(|$e$|, [|$e_1, \ldots, e_n$|])
 |$\Rightarrow$|
 |$\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}
 \end{lstlisting}
 \fi}
 \fi}
 \end{minipage}
 \end{minipage}
@@ -16254,7 +16259,8 @@ True[0]
 \begin{figure}[tp]
 \begin{figure}[tp]
 \centering
 \centering
 \fbox{
 \fbox{
-\begin{minipage}{0.97\textwidth}
+  \begin{minipage}{0.97\textwidth}
+{\if\edition\racketEd    
 \[
 \[
 \begin{array}{rcl}
 \begin{array}{rcl}
   \itm{cmp} &::= & \key{eq?} \MID \key{<} \MID \key{<=} \MID \key{>} \MID \key{>=} \\
   \itm{cmp} &::= & \key{eq?} \MID \key{<} \MID \key{<=} \MID \key{>} \MID \key{>=} \\
@@ -16277,6 +16283,10 @@ True[0]
 \LangDynM{}  &::=& \Def\ldots\; \Exp
 \LangDynM{}  &::=& \Def\ldots\; \Exp
 \end{array}
 \end{array}
 \]
 \]
+\fi}
+{\if\edition\pythonEd
+  UNDER CONSTRUCTION
+\fi}
 \end{minipage}
 \end{minipage}
 }
 }
 \caption{Syntax of \LangDyn{}, an untyped language (a subset of \racket{Racket}\python{Python}).}
 \caption{Syntax of \LangDyn{}, an untyped language (a subset of \racket{Racket}\python{Python}).}

+ 3 - 2
defs.tex

@@ -165,8 +165,9 @@
 \fi
 \fi
 
 
 \if\edition\pythonEd
 \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{\INT}[1]{{\key{Constant}\LP#1\RP}}
 \newcommand{\READOP}{{\key{input\_int}}}
 \newcommand{\READOP}{{\key{input\_int}}}
 \newcommand{\READ}{{\key{Call(Name('input\_int'),[])}}}
 \newcommand{\READ}{{\key{Call(Name('input\_int'),[])}}}