Skip to content

Commit d292dec

Browse files
committed
more edits from Carcaldi and a few to expose allocation in the Lambda chapter
1 parent dfbab8a commit d292dec

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

book.bib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,7 @@ @inproceedings{Keep:2012ab
964964

965965
@article{Church:1932aa,
966966
author = {Church, Alonzo},
967-
journal = {Annals of Mathematics},
967+
journal = {Ann. Math.},
968968
number = {2},
969969
pages = {346--366},
970970
publisher = {Annals of Mathematics},

book.tex

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
{\if\edition\pythonEd
180180
Library of Congress Cataloging-in-Publication Data\\
181181
\ \\
182-
Names: Jeremy G. Siek. \\
182+
Names: Siek, Jeremy, author. \\
183183
Title: Essentials of compilation : an incremental approach in Python / Jeremy G. Siek. \\
184184
Description: Cambridge, Massachusetts : The MIT Press, [2023] | Includes
185185
bibliographical references and index. \\
@@ -2536,7 +2536,7 @@ \section{The \LangXInt{} Assembly Language}
25362536
value. There are 16 general-purpose registers in the computer; their
25372537
names are given in figure~\ref{fig:x86-int-concrete}. A register is
25382538
written with a percent sign, \key{\%}, followed by its name,
2539-
for example \key{\%rax}.
2539+
for example, \key{\%rax}.
25402540

25412541
An immediate value is written using the notation \key{\$}$n$ where $n$
25422542
is an integer.
@@ -7870,8 +7870,9 @@ \section{The \LangIf{} Language}
78707870
Figure~\ref{fig:interp-Lif} shows the definition of the interpreter
78717871
for \LangIf{}, which inherits from the interpreter for \LangVar{}
78727872
(figure~\ref{fig:interp-Lvar}). The constants \TRUE{} and \FALSE{}
7873-
evaluate to the corresponding Boolean values, which is
7874-
inherited from the interpreter for \LangInt{} (figure~\ref{fig:interp-Lint-class}).
7873+
evaluate to the corresponding Boolean values, behavior that is
7874+
inherited from the interpreter for \LangInt{}
7875+
(figure~\ref{fig:interp-Lint-class}).
78757876
The conditional expression $\CIF{e_1}{e_2}{\itm{e_3}}$ evaluates
78767877
expression $e_1$ and then either evaluates $e_2$ or $e_3$, depending
78777878
on whether $e_1$ produced \TRUE{} or \FALSE{}. The logical operations
@@ -10835,7 +10836,7 @@ \subsection{Remove Jumps}
1083510836
\section{Further Reading}
1083610837
\label{sec:cond-further-reading}
1083710838

10838-
The algorithm for the \code{explicate\_control} pass is based on the
10839+
The algorithm for \code{explicate\_control} is based on the
1083910840
\code{expose-basic-blocks} pass in the course notes of
1084010841
\citet{Dybvig:2010aa}.
1084110842
%
@@ -12911,7 +12912,7 @@ \section{Expose Allocation}
1291112912
the \code{expose\_allocation} pass before
1291212913
\code{remove\_complex\_operands} because it generates code that
1291312914
contains complex operands. However, with some care it can also be
12914-
placed before \code{remove\_complex\_operands} which would simplify
12915+
placed before \code{remove\_complex\_operands}, which would simplify
1291512916
tuple creation by removing the need to assign the initializing
1291612917
expressions to temporary variables (see below).
1291712918

@@ -14289,7 +14290,7 @@ \section{Challenge: Arrays}
1428914290
{\if\edition\pythonEd\pythonColor
1429014291
%
1429114292
The type checker for \LangArray{} is defined in
14292-
figure~\ref{fig:type-check-Lvecof} and
14293+
figures~\ref{fig:type-check-Lvecof} and
1429314294
\ref{fig:type-check-Lvecof-part2}. The result type of a list literal
1429414295
is \code{list[T]}, where \code{T} is the type of the initializing
1429514296
expressions. The type checking of the \code{len} function and the
@@ -14586,7 +14587,7 @@ \subsection{Overload Resolution}
1458614587
Translate the reading of an array element to
1458714588
\racket{\code{vectorof-ref}}\python{\code{array\_load}}
1458814589
and the writing of an array element to
14589-
\racket{\code{vectorof-set!}}\python{\code{array\_store}}
14590+
\racket{\code{vectorof-set!}}\python{\code{array\_store}}.
1459014591
Translate calls to \racket{\code{vector-length}}\python{\code{len}}
1459114592
into \racket{\code{vectorof-length}}\python{\code{array\_len}}.
1459214593
When these operators are applied to tuples, leave them as is.
@@ -15205,10 +15206,10 @@ \section{The \LangFun{} Language}
1520515206
\code{env} with the parameters of the function. We then type check
1520615207
the body of the function and obtain the actual return type
1520715208
\code{rt}, which is either the type of the expression in a
15208-
\code{return} statement, or the \code{VoidType} if control reaches
15209+
\code{return} statement or the \code{VoidType} if control reaches
1520915210
the end of the function without a \code{return} statement. (If
1521015211
there are multiple \code{return} statements, the types of their
15211-
expressions must agree.) Finally we check that the actual return
15212+
expressions must agree.) Finally, we check that the actual return
1521215213
type \code{rt} is equal to the declared return type \code{returns}.}
1521315214
%
1521415215
To check a function \racket{application}\python{call}, we match
@@ -17888,12 +17889,16 @@ \subsection{An Example Translation}
1788817889
\section{Expose Allocation}
1788917890
\label{sec:expose-allocation-r5}
1789017891

17891-
Compile the $\CLOSURE{\itm{arity}}{\Exp^{*}}$ form into code
17892-
that allocates and initializes a tuple, similar to the translation of
17893-
the tuple creation in section~\ref{sec:expose-allocation}.
17894-
The only difference is replacing the use of
17895-
\ALLOC{\itm{len}}{\itm{type}} with
17896-
\ALLOCCLOS{\itm{len}}{\itm{type}}{\itm{arity}}.
17892+
Compile the $\CLOSURE{\itm{arity}}{\Exp^{*}}$ form into code that
17893+
allocates and initializes a tuple, similar to the translation of the
17894+
tuple creation in section~\ref{sec:expose-allocation}. The main
17895+
difference is replacing the use of \ALLOC{\itm{len}}{\itm{type}} with
17896+
\ALLOCCLOS{\itm{len}}{\itm{type}}{\itm{arity}}. The result type of
17897+
the translation of $\CLOSURE{\itm{arity}}{\Exp^{*}}$ should be a tuple
17898+
type, but only a single element tuple type. The types of the tuple
17899+
elements that correspond to the free variables of the closure should
17900+
not appear in the tuple type. The new AST class \code{UncheckedCast}
17901+
can be used to adjust the result type.
1789717902

1789817903

1789917904
\section{Explicate Control and \LangCLam{}}
@@ -17929,6 +17934,7 @@ \section{Explicate Control and \LangCLam{}}
1792917934
\Exp &::=& \key{Uninitialized}\LP \Type \RP
1793017935
\MID \key{AllocateClosure}\LP\itm{len},\Type, \itm{arity}\RP \\
1793117936
&\MID& \ARITY{\Atm}
17937+
\MID \key{UncheckedCast}\LP\Exp,\Type\RP
1793217938
\end{array}
1793317939
}
1793417940

0 commit comments

Comments
 (0)