diff --git a/book.tex b/book.tex index f25ee39..0370929 100644 --- a/book.tex +++ b/book.tex @@ -3616,7 +3616,7 @@ \section{Remove Complex Operands} \section{Explicate Control} \label{sec:explicate-control-Lvar} -The \code{explicate\_control} pass compiles \LangVar{} programs into \LangCVar{} +The \code{explicate\_control} pass compiles \LangVarANF{} programs into \LangCVar{} programs that make the order of execution explicit in their syntax. For now this amounts to flattening \key{let} constructs into a sequence of assignment statements. For example, consider the following @@ -3702,11 +3702,11 @@ \section{Explicate Control} \code{explicate\_assign} should be applied to expressions that occur on the right-hand side of a \key{let}. % -The \code{explicate\_tail} function takes an \Exp{} in \LangVar{} as +The \code{explicate\_tail} function takes an \Exp{} in \LangVarANF{} as input and produces a \Tail{} in \LangCVar{} (see figure~\ref{fig:c0-syntax}). % -The \code{explicate\_assign} function takes an \Exp{} in \LangVar{}, +The \code{explicate\_assign} function takes an \Exp{} in \LangVarANF{}, the variable to which it is to be assigned, and a \Tail{} in \LangCVar{} for the code that comes after the assignment. The \code{explicate\_assign} function returns a $\Tail$ in \LangCVar{}. @@ -3725,7 +3725,7 @@ \section{Explicate Control} \begin{exercise}\normalfont\normalsize % Implement the \code{explicate\_control} function in -\code{compiler.rkt}. Create three new \LangInt{} programs that +\code{compiler.rkt}. Create three new \LangVar{} programs that exercise the code in \code{explicate\_control}. % In the \code{run-tests.rkt} script, add the following entry to the @@ -9041,10 +9041,10 @@ \section{Explicate Control} make the order of evaluation explicit in the syntax of the program. With the addition of \key{if}, this becomes more interesting.} % -The \code{explicate\_control} pass translates from \LangIf{} to \LangCIf{}. +The \code{explicate\_control} pass translates from \LangIfANF{} to \LangCIf{}. % The main challenge to overcome is that the condition of an \key{if} -can be an arbitrary expression in \LangIf{}, whereas in \LangCIf{} the +can be an arbitrary expression in \LangIfANF{}, whereas in \LangCIf{} the condition must be a comparison. As a motivating example, consider the following program that has an @@ -9113,7 +9113,7 @@ \section{Explicate Control} \end{minipage} \end{center} One way to achieve this goal is to reorganize the code at the level of -\LangIf{}, pushing the outer \key{if} inside the inner one, yielding +\LangIf{} or \LangIfANF{}, pushing the outer \key{if} inside the inner one, yielding the following code: \begin{center} \begin{minipage}{0.96\textwidth} @@ -9263,7 +9263,7 @@ \section{Explicate Control} \end{tabular} \fi} \end{tcolorbox} -\caption{Translation from \LangIf{} to \LangCIf{} +\caption{Translation from \LangIfANF{} to \LangCIf{} via the \code{explicate\_control}.} \label{fig:explicate-control-s1-38} \end{figure} @@ -9272,15 +9272,15 @@ \section{Explicate Control} {\if\edition\racketEd % Recall that in section~\ref{sec:explicate-control-Lvar} we implement -\code{explicate\_control} for \LangVar{} using two recursive +\code{explicate\_control} for \LangVarANF{} using two recursive functions, \code{explicate\_tail} and \code{explicate\_assign}. The former function translates expressions in tail position, whereas the latter function translates expressions on the right-hand side of a -\key{let}. With the addition of \key{if} expression to \LangIf{} we +\key{let}. With the addition of \key{if} expression to \LangIfANF{} we have a new kind of position to deal with: the predicate position of the \key{if}. We need another function, \code{explicate\_pred}, that decides how to compile an \key{if} by analyzing its condition. So, -\code{explicate\_pred} takes an \LangIf{} expression and two +\code{explicate\_pred} takes an \LangIfANF{} expression and two \LangCIf{} tails for the \emph{then} branch and \emph{else} branch and outputs a tail. In the following paragraphs we discuss specific cases in the \code{explicate\_tail}, \code{explicate\_assign}, and @@ -11920,10 +11920,10 @@ \section{Explicate Control \racket{and \LangCLoop{}}} {\if\edition\racketEd Recall that in the \code{explicate\_control} pass we define one helper -function for each kind of position in the program. For the \LangVar{} +function for each kind of position in the program. For the \LangVarANF{} language of integers and variables, we needed assignment and tail -positions. The \code{if} expressions of \LangIf{} introduced predicate -positions. For \LangLoop{}, the \code{begin} expression introduces yet +positions. The \code{if} expressions of \LangIfANF{} introduced predicate +positions. For \LangLoopANF{}, the \code{begin} expression introduces yet another kind of position: effect position. Except for the last subexpression, the subexpressions inside a \code{begin} are evaluated only for their effect. Their result values are discarded. We can @@ -16036,7 +16036,7 @@ \section{Explicate Control and the \LangCFun{} Language} We recommend defining a new auxiliary function for processing function definitions. This code is similar to the case for \code{Program} in \LangVec{}. The top-level \code{explicate\_control} function that -handles the \code{ProgramDefs} form of \LangFun{} can apply this +handles the \code{ProgramDefs} form of \LangFunANF{} can apply this new function to all function definitions. {\if\edition\pythonEd\pythonColor