|
@@ -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}}
|
|
@@ -10058,13 +10058,12 @@ control-flow graphs of the later may contain cycles.
|
|
|
\label{fig:c7-syntax}
|
|
|
\end{figure}
|
|
|
|
|
|
-The new auxiliary function \code{explicate\_effect} takes an expression
|
|
|
-(in an effect position) and a promise of a continuation block. The
|
|
|
-function returns a promise for a $\Tail$ that includes the generated
|
|
|
-code for the input expression followed by the continuation block. If
|
|
|
-the expression is obviously pure, that is, never causes side effects,
|
|
|
-then the expression can be removed, so the result is just the
|
|
|
-continuation block.
|
|
|
+The new auxiliary function \code{explicate\_effect} takes an
|
|
|
+expression (in an effect position) and a continuation. The function
|
|
|
+returns a $\Tail$ that includes the generated code for the input
|
|
|
+expression followed by the continuation. If the expression is
|
|
|
+obviously pure, that is, never causes side effects, then the
|
|
|
+expression can be removed, so the result is just the continuation.
|
|
|
%
|
|
|
The $\WHILE{\itm{cnd}}{\itm{body}}$ expression is the most interesting
|
|
|
case. First, you will need a fresh label $\itm{loop}$ for the top of
|
|
@@ -10074,9 +10073,7 @@ with the a \code{goto} to $\itm{loop}$ as the continuation, producing
|
|
|
\itm{body'} as the then-branch and the continuation block as the
|
|
|
else-branch. The result should be added to the control-flow graph with
|
|
|
the label \itm{loop}. The result for the whole \code{while} loop is a
|
|
|
-\code{goto} to the \itm{loop} label. Note that the loop should only be
|
|
|
-added to the control-flow graph if the loop is indeed used, which can
|
|
|
-be accomplished using \code{delay}.
|
|
|
+\code{goto} to the \itm{loop} label.
|
|
|
|
|
|
The auxiliary functions for tail, assignment, and predicate positions
|
|
|
need to be updated. The three new language forms, \code{while},
|
|
@@ -10105,9 +10102,9 @@ the condition expression.
|
|
|
\label{sec:select-instructions-loop}
|
|
|
|
|
|
Only three small additions are needed in the
|
|
|
-\code{select\_instructions} pass to handle the changes to \LangCLoop{}. That
|
|
|
-is, \code{Call}, \code{read}, and \code{vector-set!} may now appear as
|
|
|
-stand-alone statements instead of only appearing on the right-hand
|
|
|
+\code{select\_instructions} pass to handle the changes to
|
|
|
+\LangCLoop{}. That is, a \code{Call} to \code{read} may now appear as a
|
|
|
+stand-alone statement instead of only appearing on the right-hand
|
|
|
side of an assignment statement. The code generation is nearly
|
|
|
identical; just leave off the instruction for moving the result into
|
|
|
the left-hand side.
|