Jeremy Siek 3 years ago
parent
commit
85dfd61206
1 changed files with 204 additions and 205 deletions
  1. 204 205
      book.tex

+ 204 - 205
book.tex

@@ -1984,7 +1984,7 @@ inherits from the class for \LangInt{} and the method
 {\if\edition\racketEd  
 \begin{minipage}{0.45\textwidth}
 \begin{lstlisting}
-(define interp_Lint_class
+(define interp-Lint-class
   (class object%
     (define/public ((interp_exp env) e)
       (match e
@@ -1996,8 +1996,8 @@ inherits from the class for \LangInt{} and the method
 \end{minipage}
 \begin{minipage}{0.45\textwidth}
   \begin{lstlisting}
-(define interp_Lvar_class
-  (class interp_Lint_class
+(define interp-Lvar-class
+  (class interp-Lint-class
     (define/override ((interp_exp env) e)
       (match e
         [(Var x)
@@ -2059,7 +2059,7 @@ call it \code{e0}, by creating an object of the \LangVar{} class
 and calling the \code{interp\_exp} method.
 {\if\edition\racketEd
 \begin{lstlisting}
-((send (new interp_Lvar_class) interp_exp '()) e0)
+((send (new interp-Lvar-class) interp_exp '()) e0)
 \end{lstlisting}
 \fi}
 {\if\edition\pythonEd
@@ -2156,7 +2156,7 @@ variable, it looks up the corresponding value in the dictionary.
 \begin{figure}[tp]
 {\if\edition\racketEd
 \begin{lstlisting}
-(define interp_Lint_class
+(define interp-Lint-class
   (class object%
     (super-new)
     
@@ -2222,8 +2222,8 @@ def interp_Lint(p):
 \begin{figure}[tp]
 {\if\edition\racketEd
 \begin{lstlisting}
-(define interp_Lvar_class
-  (class interp_Lint_class
+(define interp-Lvar-class
+  (class interp-Lint-class
     (super-new)
     
     (define/override ((interp_exp env) e)
@@ -2236,7 +2236,7 @@ def interp_Lint(p):
     ))
 
 (define (interp_Lvar p)
-  (send (new interp_Lvar_class) interp_program p))
+  (send (new interp-Lvar-class) interp_program p))
 \end{lstlisting}
 \fi}
 {\if\edition\pythonEd
@@ -6758,8 +6758,8 @@ evaluated if $e_1$ evaluates to \TRUE{}.
 \begin{figure}[tbp]
 {\if\edition\racketEd    
 \begin{lstlisting}
-(define interp_Lif_class
-  (class interp_Lvar_class
+(define interp-Lif-class
+  (class interp-Lvar-class
     (super-new)
 
     (define/public (interp_op op) ...)
@@ -6787,7 +6787,7 @@ evaluated if $e_1$ evaluates to \TRUE{}.
     ))
 
 (define (interp_Lif p)
-  (send (new interp_Lif_class) interp_program p))
+  (send (new interp-Lif-class) interp_program p))
 \end{lstlisting}
 \fi}
 {\if\edition\pythonEd
@@ -7016,7 +7016,7 @@ Figure~\ref{fig:type-check-Lvar}.  The type of an integer constant is
 \begin{figure}[tbp]
 {\if\edition\racketEd  
 \begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
-(define type-check-Lvar_class
+(define type-check-Lvar-class
   (class object%
     (super-new)
 
@@ -7064,7 +7064,7 @@ Figure~\ref{fig:type-check-Lvar}.  The type of an integer constant is
     ))
 
 (define (type-check-Lvar p)
-  (send (new type-check-Lvar_class) type-check-program p))
+  (send (new type-check-Lvar-class) type-check-program p))
 \end{lstlisting}
 \fi}
 {\if\edition\pythonEd
@@ -7126,8 +7126,8 @@ class TypeCheckLvar:
 \begin{figure}[tbp]
 {\if\edition\racketEd    
 \begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
-(define type-check-Lif_class
-  (class type-check-Lvar_class
+(define type-check-Lif-class
+  (class type-check-Lvar-class
     (super-new)
     (inherit check-type-equal?)
     
@@ -7161,7 +7161,7 @@ class TypeCheckLvar:
     ))
 
 (define (type-check-Lif p)
-  (send (new type-check-Lif_class) type-check-program p))
+  (send (new type-check-Lif-class) type-check-program p))
 \end{lstlisting}
 \fi}
 {\if\edition\pythonEd
@@ -9670,7 +9670,7 @@ computing the sum of the first five positive integers.
       sum)))
 \end{lstlisting}
 The \code{while} loop consists of a condition and a
-body\footnote{The \code{while} loop in particular is not a built-in
+body\footnote{The \code{while} loop is not a built-in
 feature of the Racket language, but Racket includes many looping
 constructs and it is straightforward to define \code{while} as a
 macro.}. The body is evaluated repeatedly so long as the condition
@@ -9686,18 +9686,16 @@ value. Instead their result is the \code{\#<void>} value.  The
 expression \code{(void)} is an explicit way to create the
 \code{\#<void>} value and it has type \code{Void}.  The
 \code{\#<void>} value can be passed around just like other values
-inside an \LangLoop{} program and a \code{\#<void>} value can be
-compared for equality with another \code{\#<void>} value. However,
-there are no other operations specific to the the \code{\#<void>}
-value in \LangLoop{}. In contrast, Racket defines the \code{void?}
-predicate that returns \code{\#t} when applied to \code{\#<void>} and
-\code{\#f} otherwise.
-%
-\footnote{Racket's \code{Void} type corresponds to what is called the
-  \code{Unit} type in the programming languages literature. Racket's
-  \code{Void} type is inhabited by a single value \code{\#<void>}
-  which corresponds to \code{unit} or \code{()} in the
-  literature~\citep{Pierce:2002hj}.}.
+inside an \LangLoop{} program and it can be compared for equality with
+another \code{\#<void>} value. However, there are no other operations
+specific to the the \code{\#<void>} value in \LangLoop{}. In contrast,
+Racket defines the \code{void?}  predicate that returns \code{\#t}
+when applied to \code{\#<void>} and \code{\#f} otherwise.%
+%
+\footnote{Racket's \code{Void} type corresponds to what is often
+  called the \code{Unit} type. Racket's \code{Void} type is inhabited
+  by a single value \code{\#<void>} which corresponds to \code{unit}
+  or \code{()} in the literature~\citep{Pierce:2002hj}.}.
 %
 With the addition of side-effecting features such as \code{while} loop
 and \code{set!}, it is helpful to also include in a language feature
@@ -9834,7 +9832,7 @@ Figure~\ref{fig:Lwhile-concrete-syntax} and its abstract syntax is defined
 in Figure~\ref{fig:Lwhile-syntax}.
 %
 The definitional interpreter for \LangLoop{} is shown in
-Figure~\ref{fig:interp-Rwhile}.
+Figure~\ref{fig:interp-Lwhile}.
 %
 {\if\edition\racketEd    
 %
@@ -9849,17 +9847,17 @@ value.
 Now to discuss the new cases. For \code{SetBang}, we lookup the
 variable in the environment to obtain a boxed value and then we change
 it using \code{set-box!} to the result of evaluating the right-hand
-side.  The result value of a \code{SetBang} is \code{void}.
+side.  The result value of a \code{SetBang} is \code{\#<void>}.
 %
 For the \code{WhileLoop}, we repeatedly 1) evaluate the condition, and
 if the result is true, 2) evaluate the body.
-The result value of a \code{while} loop is also \code{void}.
+The result value of a \code{while} loop is also \code{\#<void>}.
 %
 The $\BEGIN{\itm{es}}{\itm{body}}$ expression evaluates the
 subexpressions \itm{es} for their effects and then evaluates
 and returns the result from \itm{body}.
 %
-The $\VOID{}$ expression produces the \code{void} value.
+The $\VOID{}$ expression produces the \code{\#<void>} value.
 %
 \fi}
 {\if\edition\pythonEd
@@ -9874,15 +9872,19 @@ function, where we repeatedly interpret the \code{body} so long as the
 \begin{figure}[tbp]
 {\if\edition\racketEd    
 \begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
-(define interp-Rwhile_class
-  (class interp-Rany_class
+(define interp-Lwhile-class
+  (class interp-Lif-class
     (super-new)
 
     (define/override ((interp-exp env) e)
       (define recur (interp-exp env))
       (match e
+        [(Let x e body)
+         (define new-env (dict-set env x (box (recur e))))
+         ((interp-exp new-env) body)]
+        [(Var x) (unbox (dict-ref env x))]
         [(SetBang x rhs)
-         (set-box! (lookup x env) (recur rhs))]
+         (set-box! (dict-ref env x) (recur rhs))]
         [(WhileLoop cnd body)
          (define (loop)
            (cond [(recur cnd)  (recur body) (loop)]
@@ -9895,8 +9897,8 @@ function, where we repeatedly interpret the \code{body} so long as the
         [else ((super interp-exp env) e)]))
     ))
 
-(define (interp-Rwhile p)
-  (send (new interp-Rwhile_class) interp-program p))
+(define (interp-Lwhile p)
+  (send (new interp-Lwhile-class) interp-program p))
 \end{lstlisting}
 \fi}
 {\if\edition\pythonEd
@@ -9915,22 +9917,19 @@ class InterpLwhile(InterpLif):
 \end{lstlisting}
 \fi}
 \caption{Interpreter for \LangLoop{}.}
-\label{fig:interp-Rwhile}
+\label{fig:interp-Lwhile}
 \end{figure}
 
 The type checker for \LangLoop{} is defined in
-Figure~\ref{fig:type-check-Rwhile}.
+Figure~\ref{fig:type-check-Lwhile}.
 %
 {\if\edition\racketEd    
 %
-For \LangLoop{} we add a type named \code{Void} and the only value of
-this type is the \code{void} value.
-%
-The type checking of the \code{SetBang} expression requires the type of
-the variable and the right-hand-side to agree. The result type is
-\code{Void}. For \code{while}, the condition must be a
-\code{Boolean}. The result type is also \code{Void}.  For
-\code{Begin}, the result type is the type of its last subexpression.
+The type checking of the \code{SetBang} expression requires the type
+of the variable and the right-hand-side to agree. The result type is
+\code{Void}. For \code{while}, the condition must be a \code{Boolean}
+and the result type is \code{Void}.  For \code{Begin}, the result type
+is the type of its last subexpression.
 %
 \fi}
 %
@@ -9945,8 +9944,8 @@ well typed.
 \begin{figure}[tbp]
 {\if\edition\racketEd    
 \begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
-(define type-check-Rwhile_class
-  (class type-check-Rany_class
+(define type-check-Lwhile-class
+  (class type-check-Lif-class
     (super-new)
     (inherit check-type-equal?)
 
@@ -9972,8 +9971,8 @@ well typed.
           [else ((super type-check-exp env) e)])))
     ))
 
-(define (type-check-Rwhile p)
-  (send (new type-check-Rwhile_class) type-check-program p))
+(define (type-check-Lwhile p)
+  (send (new type-check-Lwhile-class) type-check-program p))
 \end{lstlisting}
 \fi}
 {\if\edition\pythonEd
@@ -9994,7 +9993,7 @@ class TypeCheckLwhile(TypeCheckLif):
 \end{lstlisting}
 \fi}
 \caption{Type checker for the \LangLoop{} language.}
-\label{fig:type-check-Rwhile}
+\label{fig:type-check-Lwhile}
 \end{figure}
 
 
@@ -10488,7 +10487,7 @@ statement.
 %
 \fi}  
 %
-Figure~\ref{fig:Rwhile-anf-syntax} defines the output language
+Figure~\ref{fig:Lwhile-anf-syntax} defines the output language
 \LangLoopANF{} of this pass.
 
 
@@ -10542,7 +10541,7 @@ Figure~\ref{fig:Rwhile-anf-syntax} defines the output language
 \end{minipage}
 }
 \caption{\LangLoopANF{} is \LangLoop{} in monadic normal form.}
-\label{fig:Rwhile-anf-syntax}
+\label{fig:Lwhile-anf-syntax}
 \end{figure}
 
 {\if\edition\racketEd    
@@ -10731,10 +10730,10 @@ The \code{analyze\_dataflow} function has four parameters.
 
 \begin{figure}[p]
 \begin{tikzpicture}[baseline=(current  bounding  box.center)]
-\node (Rfun) at (0,2)  {\large \LangLoop{}};
-\node (Rfun-2) at (3,2)  {\large \LangLoop{}};
-%\node (Rfun-3) at (6,2)  {\large \LangLoop{}};
-%\node (Rfun-4) at (9,2)  {\large \LangLoopFunRef{}};
+\node (Lfun) at (0,2)  {\large \LangLoop{}};
+\node (Lfun-2) at (3,2)  {\large \LangLoop{}};
+%\node (Lfun-3) at (6,2)  {\large \LangLoop{}};
+%\node (Lfun-4) at (9,2)  {\large \LangLoopFunRef{}};
 %\node (F1-1) at (12,0)  {\large \LangLoopFunRef{}};
 %\node (F1-2) at (9,0)  {\large \LangLoopFunRef{}};
 %\node (F1-3) at (6,0)  {\large \LangLoopFunRef{}};
@@ -10750,17 +10749,17 @@ The \code{analyze\_dataflow} function has four parameters.
 \node (x86-5) at (9,-4) {\large \LangXIf{}};
 
 
-%% \path[->,bend left=15] (Rfun) edge [above] node
-%%      {\ttfamily\footnotesize type-check} (Rfun-2);
-\path[->,bend left=15] (Rfun) edge [above] node
-     {\ttfamily\footnotesize shrink} (Rfun-2);
-\path[->,bend left=15] (Rfun-2) edge [above] node
+%% \path[->,bend left=15] (Lfun) edge [above] node
+%%      {\ttfamily\footnotesize type-check} (Lfun-2);
+\path[->,bend left=15] (Lfun) edge [above] node
+     {\ttfamily\footnotesize shrink} (Lfun-2);
+\path[->,bend left=15] (Lfun-2) edge [above] node
      {\ttfamily\footnotesize uniquify} (F1-4);
-%% \path[->,bend left=15] (Rfun-3) edge [above] node
-%%      {\ttfamily\footnotesize reveal\_functions} (Rfun-4);
-%% \path[->,bend left=15] (Rfun-4) edge [right] node
+%% \path[->,bend left=15] (Lfun-3) edge [above] node
+%%      {\ttfamily\footnotesize reveal\_functions} (Lfun-4);
+%% \path[->,bend left=15] (Lfun-4) edge [right] node
 %%      {\ttfamily\footnotesize convert\_assignments} (F1-1);
-%% \path[->,bend left=15] (Rfun-4) edge [right] node
+%% \path[->,bend left=15] (Lfun-4) edge [right] node
 %%      {\ttfamily\footnotesize convert\_to\_clos.} (F1-2);
 %% \path[->,bend right=15] (F1-2) edge [above] node
 %%      {\ttfamily\footnotesize limit\_fun.} (F1-3);
@@ -10783,10 +10782,10 @@ The \code{analyze\_dataflow} function has four parameters.
 \path[->,bend left=15] (x86-4) edge [right] node {\ttfamily\footnotesize prelude\_and\_concl.} (x86-5);
 \end{tikzpicture}
   \caption{Diagram of the passes for \LangLoop{}.}
-\label{fig:Rwhile-passes}
+\label{fig:Lwhile-passes}
 \end{figure}
 
-Figure~\ref{fig:Rwhile-passes} provides an overview of all the passes needed
+Figure~\ref{fig:Lwhile-passes} provides an overview of all the passes needed
 for the compilation of \LangLoop{}.
 
 
@@ -11107,8 +11106,8 @@ Figure~\ref{fig:interp-Lvec} shows the definitional interpreter for the
 \begin{figure}[tbp]
 {\if\edition\racketEd
 \begin{lstlisting}
-(define interp-Lvec_class
-  (class interp-Lif_class
+(define interp-Lvec-class
+  (class interp-Lif-class
     (super-new)
 
     (define/override (interp-op op)
@@ -11136,7 +11135,7 @@ Figure~\ref{fig:interp-Lvec} shows the definitional interpreter for the
     ))
 
 (define (interp-Lvec p)
-  (send (new interp-Lvec_class) interp-program p))
+  (send (new interp-Lvec-class) interp-program p))
 \end{lstlisting}
 \fi}
 %
@@ -11189,8 +11188,8 @@ start and end parentheses. \index{subject}{unquote-slicing}}
 \begin{figure}[tp]
 {\if\edition\racketEd
 \begin{lstlisting}[basicstyle=\ttfamily\scriptsize]
-(define type-check-Lvec_class
-  (class type-check-Lif_class
+(define type-check-Lvec-class
+  (class type-check-Lif-class
     (super-new)
     (inherit check-type-equal?)
 
@@ -11245,7 +11244,7 @@ start and end parentheses. \index{subject}{unquote-slicing}}
     ))
 
 (define (type-check-Lvec p)
-  (send (new type-check-Lvec_class) type-check-program p))
+  (send (new type-check-Lvec-class) type-check-program p))
 \end{lstlisting}
 \fi}
 {\if\edition\pythonEd
@@ -12709,8 +12708,8 @@ predicate.
 
 \begin{figure}[tbp]
 \begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
-(define type-check-Lvecof_class
-  (class type-check-Rwhile_class
+(define type-check-Lvecof-class
+  (class type-check-Lwhile-class
     (super-new)
     (inherit check-type-equal?)
 
@@ -12759,7 +12758,7 @@ predicate.
     ))
 
 (define (type-check-Lvecof p)
-  (send (new type-check-Lvecof_class) type-check-program p))
+  (send (new type-check-Lvecof-class) type-check-program p))
 \end{lstlisting}
 \caption{Type checker for the \LangArray{} language.}
 \label{fig:type-check-Lvecof}
@@ -12773,8 +12772,8 @@ integers.
 
 \begin{figure}[tbp]
 \begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
-(define interp-Lvecof_class
-  (class interp-Rwhile_class
+(define interp-Lvecof-class
+  (class interp-Lwhile-class
     (super-new)
 
     (define/override (interp-op op)
@@ -12786,7 +12785,7 @@ integers.
     ))
 
 (define (interp-Lvecof p)
-  (send (new interp-Lvecof_class) interp-program p))
+  (send (new interp-Lvecof-class) interp-program p))
 \end{lstlisting}
 \caption{Interpreter for \LangArray{}.}
 \label{fig:interp-Lvecof}
@@ -13047,21 +13046,21 @@ abstractions, which is the topic of Chapter~\ref{ch:Llambda}.
 \section{The \LangFun{} Language}
 
 The concrete and abstract syntax for function definitions and function
-application is shown in Figures~\ref{fig:Rfun-concrete-syntax} and
-\ref{fig:Rfun-syntax}, where we define the \LangFun{} language.  Programs in
+application is shown in Figures~\ref{fig:Lfun-concrete-syntax} and
+\ref{fig:Lfun-syntax}, where we define the \LangFun{} language.  Programs in
 \LangFun{} begin with zero or more function definitions.  The function
 names from these definitions are in-scope for the entire program,
 including all other function definitions (so the ordering of function
 definitions does not matter).
 %
 \python{The abstract syntax for function parameters in
-  Figure~\ref{fig:Rfun-syntax} is a list of pairs, where each pair
+  Figure~\ref{fig:Lfun-syntax} is a list of pairs, where each pair
   consists of a parameter name and its type.  This design differs from
   Python's \code{ast} module, which has a more complex structure for
   function parameters to handle keyword parameters,
   defaults, and so on. The type checker in \code{type\_check\_Lfun} converts the
   complex Python abstract syntax into the simpler syntax of
-  Figure~\ref{fig:Rfun-syntax}. The fourth and sixth parameters of the
+  Figure~\ref{fig:Lfun-syntax}. The fourth and sixth parameters of the
   \code{FunctionDef} constructor are for decorators and a type
   comment, neither of which are used by our compiler. We recommend
   replacing them with \code{None} in the \code{shrink} pass.
@@ -13182,7 +13181,7 @@ nested inside each other.
 \end{minipage}
 }
 \caption{The concrete syntax of \LangFun{}, extending \LangVec{} (Figure~\ref{fig:Lvec-concrete-syntax}).}
-\label{fig:Rfun-concrete-syntax}
+\label{fig:Lfun-concrete-syntax}
 \end{figure}
 
 \begin{figure}[tp]
@@ -13223,11 +13222,11 @@ nested inside each other.
 \end{minipage}
 }
 \caption{The abstract syntax of \LangFun{}, extending \LangVec{} (Figure~\ref{fig:Lvec-syntax}).}
-\label{fig:Rfun-syntax}
+\label{fig:Lfun-syntax}
 \end{figure}
 
 
-The program in Figure~\ref{fig:Rfun-function-example} is a
+The program in Figure~\ref{fig:Lfun-function-example} is a
 representative example of defining and using functions in \LangFun{}.
 We define a function \code{map} that applies some other function
 \code{f} to both elements of a tuple and returns a new tuple
@@ -13265,11 +13264,11 @@ print( map(inc, (0, 41))[1] )
 \end{lstlisting}
 \fi}
 \caption{Example of using functions in \LangFun{}.}
-\label{fig:Rfun-function-example}
+\label{fig:Lfun-function-example}
 \end{figure}
 
 The definitional interpreter for \LangFun{} is in
-Figure~\ref{fig:interp-Rfun}. The case for the
+Figure~\ref{fig:interp-Lfun}. The case for the
 %
 \racket{\code{ProgramDefsExp}}\python{\code{Module}}
 %
@@ -13301,8 +13300,8 @@ this extended environment.
 \begin{figure}[tp]
 {\if\edition\racketEd  
 \begin{lstlisting}
-(define interp-Rfun_class
-  (class interp-Lvec_class
+(define interp-Lfun-class
+  (class interp-Lvec-class
     (super-new)
 
     (define/override ((interp-exp env) e)
@@ -13341,8 +13340,8 @@ this extended environment.
            ((interp-exp top-level) body))]))
     ))
 
-(define (interp-Rfun p)
-  (send (new interp-Rfun_class) interp-program p))
+(define (interp-Lfun p)
+  (send (new interp-Lfun-class) interp-program p))
 \end{lstlisting}
 \fi}
 {\if\edition\pythonEd
@@ -13393,14 +13392,14 @@ class InterpLfun(InterpLtup):
 \end{lstlisting}
 \fi}
 \caption{Interpreter for the \LangFun{} language.}
-\label{fig:interp-Rfun}
+\label{fig:interp-Lfun}
 \end{figure}
 
 
 %\margincomment{TODO: explain type checker}
 
 The type checker for \LangFun{} is in
-Figure~\ref{fig:type-check-Rfun}.  (We omit the code that parses
+Figure~\ref{fig:type-check-Lfun}.  (We omit the code that parses
 function parameters into the simpler abstract syntax.)  Similar to the
 interpreter, the case for the
 \racket{\code{ProgramDefsExp}}\python{\code{Module}}
@@ -13420,8 +13419,8 @@ a whole is the return type from the function type.
 \begin{figure}[tp]
 {\if\edition\racketEd  
 \begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
-(define type-check-Rfun_class
-  (class type-check-Lvec_class
+(define type-check-Lfun-class
+  (class type-check-Lvec-class
     (super-new)
     (inherit check-type-equal?)
 
@@ -13471,8 +13470,8 @@ a whole is the return type from the function type.
          (check-type-equal? ty 'Integer body)
          (ProgramDefsExp info ds^ body^)]))))
 
-(define (type-check-Rfun p)
-  (send (new type-check-Rfun_class) type-check-program p))
+(define (type-check-Lfun p)
+  (send (new type-check-Lfun-class) type-check-program p))
 \end{lstlisting}
 \fi}
 {\if\edition\pythonEd
@@ -13528,7 +13527,7 @@ class TypeCheckLfun(TypeCheckLtup):
 \end{lstlisting}
 \fi}
 \caption{Type checker for the \LangFun{} language.}
-\label{fig:type-check-Rfun}
+\label{fig:type-check-Lfun}
 \end{figure}
 
 
@@ -13864,7 +13863,7 @@ is defined in Figure~\ref{fig:f1-syntax}.
 \end{minipage}
 }
 \caption{The abstract syntax \LangFunRef{}, an extension of \LangFun{}
-  (Figure~\ref{fig:Rfun-syntax}).}
+  (Figure~\ref{fig:Lfun-syntax}).}
 \label{fig:f1-syntax}
 \end{figure}
 
@@ -13990,7 +13989,7 @@ and \racket{\code{Apply}}\python{\code{Call}} in the grammar for expressions.
 % TODO: Return?
 
 
-%% Figure~\ref{fig:Rfun-anf-syntax} defines the output language
+%% Figure~\ref{fig:Lfun-anf-syntax} defines the output language
 %% \LangFunANF{} of this pass.
 
 %% \begin{figure}[tp]
@@ -14017,7 +14016,7 @@ and \racket{\code{Apply}}\python{\code{Call}} in the grammar for expressions.
 %% \end{minipage}
 %% }
 %% \caption{\LangFunANF{} is \LangFunRefAlloc{} in monadic normal form.}
-%% \label{fig:Rfun-anf-syntax}
+%% \label{fig:Lfun-anf-syntax}
 %% \end{figure}
 
 
@@ -14471,9 +14470,9 @@ previously created test programs.
 
 \begin{figure}[tbp]
 \begin{tikzpicture}[baseline=(current  bounding  box.center)]
-\node (Rfun) at (0,2)  {\large \LangFun{}};
-\node (Rfun-1) at (3,2)  {\large \LangFun{}};
-\node (Rfun-2) at (6,2)  {\large \LangFun{}};
+\node (Lfun) at (0,2)  {\large \LangFun{}};
+\node (Lfun-1) at (3,2)  {\large \LangFun{}};
+\node (Lfun-2) at (6,2)  {\large \LangFun{}};
 \node (F1-1) at (9,2)  {\large \LangFunRef{}};
 \node (F1-2) at (9,0)  {\large \LangFunRef{}};
 \node (F1-3) at (6,0)  {\large \LangFunRefAlloc{}};
@@ -14488,11 +14487,11 @@ previously created test programs.
 \node (x86-2-1) at (3,-6)  {\large \LangXIndCallVar{}};
 \node (x86-2-2) at (6,-6)  {\large \LangXIndCallVar{}};
 
-\path[->,bend left=15] (Rfun) edge [above] node
-     {\ttfamily\footnotesize shrink} (Rfun-1);
-\path[->,bend left=15] (Rfun-1) edge [above] node
-     {\ttfamily\footnotesize uniquify} (Rfun-2);
-\path[->,bend left=15] (Rfun-2) edge [above] node
+\path[->,bend left=15] (Lfun) edge [above] node
+     {\ttfamily\footnotesize shrink} (Lfun-1);
+\path[->,bend left=15] (Lfun-1) edge [above] node
+     {\ttfamily\footnotesize uniquify} (Lfun-2);
+\path[->,bend left=15] (Lfun-2) edge [above] node
      {\ttfamily\footnotesize ~~reveal\_functions} (F1-1);
 \path[->,bend left=15] (F1-1) edge [right] node
      {\ttfamily\footnotesize limit\_functions} (F1-2);
@@ -14515,10 +14514,10 @@ previously created test programs.
 \path[->,bend right=15] (x86-4) edge [left] node {\ttfamily\footnotesize print-x86} (x86-5);
 \end{tikzpicture}
 \caption{Diagram of the passes for \LangFun{}, a language with functions.}
-\label{fig:Rfun-passes}
+\label{fig:Lfun-passes}
 \end{figure}
 
-Figure~\ref{fig:Rfun-passes} gives an overview of the passes for
+Figure~\ref{fig:Lfun-passes} gives an overview of the passes for
 compiling \LangFun{} to x86.
 
 \section{An Example Translation}
@@ -14972,7 +14971,7 @@ syntax for function application.
 \fi}
 \end{minipage}
 }
-\caption{The concrete syntax of \LangLam{}, extending \LangFun{} (Figure~\ref{fig:Rfun-concrete-syntax}) 
+\caption{The concrete syntax of \LangLam{}, extending \LangFun{} (Figure~\ref{fig:Lfun-concrete-syntax}) 
   with \key{lambda}.}
 \label{fig:Rlam-concrete-syntax}
 \end{figure}
@@ -15016,7 +15015,7 @@ syntax for function application.
 \fi}
 \end{minipage}
 }
-\caption{The abstract syntax of \LangLam{}, extending \LangFun{} (Figure~\ref{fig:Rfun-syntax}).}
+\caption{The abstract syntax of \LangLam{}, extending \LangFun{} (Figure~\ref{fig:Lfun-syntax}).}
 \label{fig:Rlam-syntax}
 \end{figure}
 
@@ -15033,8 +15032,8 @@ interpret the body of the function.
 \begin{figure}[tbp]
 {\if\edition\racketEd 
 \begin{lstlisting}
-(define interp-Rlambda_class
-  (class interp-Rfun_class
+(define interp-Llambda-class
+  (class interp-Lfun-class
     (super-new)
 
     (define/override (interp-op op)
@@ -15055,7 +15054,7 @@ interpret the body of the function.
     ))
 
 (define (interp-Rlambda p)
-  (send (new interp-Rlambda_class) interp-program p))
+  (send (new interp-Llambda-class) interp-program p))
 \end{lstlisting}
 \fi}
 {\if\edition\pythonEd
@@ -16069,9 +16068,9 @@ $58$ from the tag.}
 
 \begin{figure}[p]
 \begin{tikzpicture}[baseline=(current  bounding  box.center)]
-\node (Rfun) at (0,2)  {\large \LangLam{}};
-\node (Rfun-2) at (3,2)  {\large \LangLam{}};
-\node (Rfun-3) at (6,2)  {\large \LangLam{}};
+\node (Lfun) at (0,2)  {\large \LangLam{}};
+\node (Lfun-2) at (3,2)  {\large \LangLam{}};
+\node (Lfun-3) at (6,2)  {\large \LangLam{}};
 \node (F1-0) at (9,2)  {\large \LangLamFunRef{}};
 \node (F1-1) at (12,0)  {\large \LangLamFunRef{}};
 \node (F1-2) at (9,0)  {\large \LangFunRef{}};
@@ -16087,11 +16086,11 @@ $58$ from the tag.}
 \node (x86-4) at (9,-4) {\large \LangXIndCall{}};
 \node (x86-5) at (9,-6) {\large \LangXIndCall{}};
 
-\path[->,bend left=15] (Rfun) edge [above] node
-     {\ttfamily\footnotesize shrink} (Rfun-2);
-\path[->,bend left=15] (Rfun-2) edge [above] node
-     {\ttfamily\footnotesize uniquify} (Rfun-3);
-\path[->,bend left=15] (Rfun-3) edge [above] node
+\path[->,bend left=15] (Lfun) edge [above] node
+     {\ttfamily\footnotesize shrink} (Lfun-2);
+\path[->,bend left=15] (Lfun-2) edge [above] node
+     {\ttfamily\footnotesize uniquify} (Lfun-3);
+\path[->,bend left=15] (Lfun-3) edge [above] node
      {\ttfamily\footnotesize reveal\_functions} (F1-0);
 \path[->,bend left=15] (F1-0) edge [right] node
      {\ttfamily\footnotesize convert\_assign.} (F1-1);
@@ -17034,15 +17033,15 @@ Figure~\ref{fig:type-check-Rany}
 \racket{ and uses the auxiliary functions in
 Figure~\ref{fig:type-check-Rany-aux}}.
 %
-The interpreter for \LangAny{} is in Figure~\ref{fig:interp-Rany} and
-its auxiliary functions are in Figure~\ref{fig:interp-Rany-aux}.
+The interpreter for \LangAny{} is in Figure~\ref{fig:interp-Lany} and
+its auxiliary functions are in Figure~\ref{fig:interp-Lany-aux}.
 
 
 \begin{figure}[btp]
 {\if\edition\racketEd
 \begin{lstlisting}[basicstyle=\ttfamily\small]
-(define type-check-Rany_class
-  (class type-check-Rlambda_class
+(define type-check-Rany-class
+  (class type-check-Rlambda-class
     (super-new)
     (inherit check-type-equal?)
 
@@ -17211,8 +17210,8 @@ class TypeCheckLany(TypeCheckLlambda):
 \begin{figure}[btp]
 {\if\edition\racketEd
 \begin{lstlisting}
-(define interp-Rany_class
-  (class interp-Rlambda_class
+(define interp-Lany-class
+  (class interp-Llambda-class
     (super-new)
 
     (define/override (interp-op op)
@@ -17249,8 +17248,8 @@ class TypeCheckLany(TypeCheckLlambda):
         [else ((super interp-exp env) e)]))
     ))
 
-(define (interp-Rany p)
-  (send (new interp-Rany_class) interp-program p))
+(define (interp-Lany p)
+  (send (new interp-Lany-class) interp-program p))
 \end{lstlisting}
 \fi}
 {\if\edition\pythonEd
@@ -17326,7 +17325,7 @@ class InterpLany(InterpLlambda):
 \end{lstlisting}
 \fi}
 \caption{Interpreter for \LangAny{}.}
-\label{fig:interp-Rany}
+\label{fig:interp-Lany}
 \end{figure}
 
 \begin{figure}[tbp]
@@ -17392,7 +17391,7 @@ class InterpLany(InterpLlambda):
 \end{lstlisting}
 \fi}
   \caption{Auxiliary functions for interpreting \LangAny{}.}
-  \label{fig:interp-Rany-aux}
+  \label{fig:interp-Lany-aux}
 \end{figure}
 
 \clearpage
@@ -18208,13 +18207,13 @@ completion without error.
 
 \begin{figure}[p]
 \begin{tikzpicture}[baseline=(current  bounding  box.center)]
-\node (Rfun) at (0,4)  {\large \LangDyn{}};
-\node (Rfun-2) at (3,4)  {\large \LangDyn{}};
-\node (Rfun-3) at (6,4)  {\large \LangDyn{}};
-\node (Rfun-4) at (9,4)  {\large \LangDynFunRef{}};
-\node (Rfun-5) at (9,2)  {\large \LangAnyFunRef{}};
-\node (Rfun-6) at (12,2)  {\large \LangAnyFunRef{}};
-\node (Rfun-7) at (12,0)  {\large \LangAnyFunRef{}};
+\node (Lfun) at (0,4)  {\large \LangDyn{}};
+\node (Lfun-2) at (3,4)  {\large \LangDyn{}};
+\node (Lfun-3) at (6,4)  {\large \LangDyn{}};
+\node (Lfun-4) at (9,4)  {\large \LangDynFunRef{}};
+\node (Lfun-5) at (9,2)  {\large \LangAnyFunRef{}};
+\node (Lfun-6) at (12,2)  {\large \LangAnyFunRef{}};
+\node (Lfun-7) at (12,0)  {\large \LangAnyFunRef{}};
 
 \node (F1-2) at (9,0)  {\large \LangAnyFunRef{}};
 \node (F1-3) at (6,0)  {\large \LangAnyFunRef{}};
@@ -18229,20 +18228,20 @@ completion without error.
 \node (x86-4) at (9,-4) {\large \LangXIndCall{}};
 \node (x86-5) at (9,-6) {\large \LangXIndCall{}};
 
-\path[->,bend left=15] (Rfun) edge [above] node
-     {\ttfamily\footnotesize shrink} (Rfun-2);
-\path[->,bend left=15] (Rfun-2) edge [above] node
-     {\ttfamily\footnotesize uniquify} (Rfun-3);
-\path[->,bend left=15] (Rfun-3) edge [above] node
-     {\ttfamily\footnotesize reveal\_functions} (Rfun-4);
-\path[->,bend right=15] (Rfun-4) edge [left] node
-     {\ttfamily\footnotesize cast\_insert} (Rfun-5);
-\path[->,bend left=15] (Rfun-5) edge [above] node
-     {\ttfamily\footnotesize reveal\_casts} (Rfun-6);
-\path[->,bend left=15] (Rfun-6) edge [left] node
-     {\ttfamily\footnotesize convert\_assign.} (Rfun-7);
+\path[->,bend left=15] (Lfun) edge [above] node
+     {\ttfamily\footnotesize shrink} (Lfun-2);
+\path[->,bend left=15] (Lfun-2) edge [above] node
+     {\ttfamily\footnotesize uniquify} (Lfun-3);
+\path[->,bend left=15] (Lfun-3) edge [above] node
+     {\ttfamily\footnotesize reveal\_functions} (Lfun-4);
+\path[->,bend right=15] (Lfun-4) edge [left] node
+     {\ttfamily\footnotesize cast\_insert} (Lfun-5);
+\path[->,bend left=15] (Lfun-5) edge [above] node
+     {\ttfamily\footnotesize reveal\_casts} (Lfun-6);
+\path[->,bend left=15] (Lfun-6) edge [left] node
+     {\ttfamily\footnotesize convert\_assign.} (Lfun-7);
      
-\path[->,bend left=15] (Rfun-7) edge [below] node
+\path[->,bend left=15] (Lfun-7) edge [below] node
      {\ttfamily\footnotesize convert\_to\_clos.} (F1-2);
 \path[->,bend right=15] (F1-2) edge [above] node
      {\ttfamily\footnotesize limit\_fun.} (F1-3);
@@ -18540,8 +18539,8 @@ and \ref{fig:type-check-Rgradual-3}.
 
 \begin{figure}[tbp]
 \begin{lstlisting}[basicstyle=\ttfamily\scriptsize]
-(define type-check-gradual_class
-  (class type-check-Rwhile_class
+(define type-check-gradual-class
+  (class type-check-Lwhile-class
     (super-new)
     (inherit operator-types type-predicates)
 
@@ -18784,11 +18783,11 @@ casts involving simple types such as \code{Integer} and
 \code{Boolean}.  For example, a cast from \code{Integer} to \code{Any}
 can be accomplished with the \code{Inject} operator of \LangAny{}, which
 puts the integer into a tagged value
-(Figure~\ref{fig:interp-Rany}). Similarly, a cast from \code{Any} to
+(Figure~\ref{fig:interp-Lany}). Similarly, a cast from \code{Any} to
 \code{Integer} is accomplished with the \code{Project} operator, that
 is, by checking the value's tag and either retrieving the underlying
 integer or signaling an error if it the tag is not the one for
-integers (Figure~\ref{fig:interp-Rany-aux}).
+integers (Figure~\ref{fig:interp-Lany-aux}).
 %
 Things get more interesting for higher-order casts, that is, casts
 involving function or vector types.
@@ -18931,15 +18930,15 @@ of the kinds of casts that we've discussed in this section.
 \end{figure}
 
 The interpreter for \LangCast{} is defined in
-Figure~\ref{fig:interp-Rcast}, with the case for \code{Cast}
+Figure~\ref{fig:interp-Lcast}, with the case for \code{Cast}
 dispatching to \code{apply-cast}. To handle the addition of vector
 proxies, we update the vector primitives in \code{interp-op} using the
 functions in Figure~\ref{fig:guarded-vector}.
 
 \begin{figure}[tbp]
 \begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
-(define interp-Rcast_class
-  (class interp-Rwhile_class
+(define interp-Lcast-class
+  (class interp-Lwhile-class
     (super-new)
     (inherit apply-fun apply-inject apply-project)
 
@@ -18968,11 +18967,11 @@ functions in Figure~\ref{fig:guarded-vector}.
         [else ((super interp-exp env) e)]))
     ))
 
-(define (interp-Rcast p)
-  (send (new interp-Rcast_class) interp-program p))
+(define (interp-Lcast p)
+  (send (new interp-Lcast-class) interp-program p))
 \end{lstlisting}
 \caption{The interpreter for \LangCast{}.}
-  \label{fig:interp-Rcast}
+  \label{fig:interp-Lcast}
 \end{figure}
 
 
@@ -19349,12 +19348,12 @@ be translated in a similar way.
 \begin{tikzpicture}[baseline=(current  bounding  box.center)]
 \node (Rgradual) at (6,4)  {\large \LangGrad{}};
 \node (Rgradualp) at (3,4)  {\large \LangCast{}};
-\node (Rwhilepp) at (0,4)  {\large \LangProxy{}};
-\node (Rwhileproxy) at (0,2)  {\large \LangPVec{}};
-\node (Rwhileproxy-2) at (3,2)  {\large \LangPVec{}};
-\node (Rwhileproxy-3) at (6,2)  {\large \LangPVec{}};
-\node (Rwhileproxy-4) at (9,2)  {\large \LangPVecFunRef{}};
-\node (Rwhileproxy-5) at (12,2)  {\large \LangPVecFunRef{}};
+\node (Lwhilepp) at (0,4)  {\large \LangProxy{}};
+\node (Lwhileproxy) at (0,2)  {\large \LangPVec{}};
+\node (Lwhileproxy-2) at (3,2)  {\large \LangPVec{}};
+\node (Lwhileproxy-3) at (6,2)  {\large \LangPVec{}};
+\node (Lwhileproxy-4) at (9,2)  {\large \LangPVecFunRef{}};
+\node (Lwhileproxy-5) at (12,2)  {\large \LangPVecFunRef{}};
 \node (F1-1) at (12,0)  {\large \LangPVecFunRef{}};
 \node (F1-2) at (9,0)  {\large \LangPVecFunRef{}};
 \node (F1-3) at (6,0)  {\large \LangPVecFunRef{}};
@@ -19373,18 +19372,18 @@ be translated in a similar way.
 \path[->,bend right=15] (Rgradual) edge [above] node
      {\ttfamily\footnotesize type\_check} (Rgradualp);
 \path[->,bend right=15] (Rgradualp) edge [above] node
-     {\ttfamily\footnotesize lower\_casts} (Rwhilepp);
-\path[->,bend right=15] (Rwhilepp) edge [right] node
-     {\ttfamily\footnotesize differentiate\_proxies} (Rwhileproxy);
-\path[->,bend left=15] (Rwhileproxy) edge [above] node
-     {\ttfamily\footnotesize shrink} (Rwhileproxy-2);
-\path[->,bend left=15] (Rwhileproxy-2) edge [above] node
-     {\ttfamily\footnotesize uniquify} (Rwhileproxy-3);
-\path[->,bend left=15] (Rwhileproxy-3) edge [above] node
-     {\ttfamily\footnotesize reveal\_functions} (Rwhileproxy-4);
-\path[->,bend left=15] (Rwhileproxy-4) edge [above] node
-     {\ttfamily\footnotesize reveal\_casts} (Rwhileproxy-5);
-\path[->,bend left=15] (Rwhileproxy-5) edge [left] node
+     {\ttfamily\footnotesize lower\_casts} (Lwhilepp);
+\path[->,bend right=15] (Lwhilepp) edge [right] node
+     {\ttfamily\footnotesize differentiate\_proxies} (Lwhileproxy);
+\path[->,bend left=15] (Lwhileproxy) edge [above] node
+     {\ttfamily\footnotesize shrink} (Lwhileproxy-2);
+\path[->,bend left=15] (Lwhileproxy-2) edge [above] node
+     {\ttfamily\footnotesize uniquify} (Lwhileproxy-3);
+\path[->,bend left=15] (Lwhileproxy-3) edge [above] node
+     {\ttfamily\footnotesize reveal\_functions} (Lwhileproxy-4);
+\path[->,bend left=15] (Lwhileproxy-4) edge [above] node
+     {\ttfamily\footnotesize reveal\_casts} (Lwhileproxy-5);
+\path[->,bend left=15] (Lwhileproxy-5) edge [left] node
      {\ttfamily\footnotesize convert\_assignments} (F1-1);
 \path[->,bend left=15] (F1-1) edge [below] node
      {\ttfamily\footnotesize convert\_to\_clos.} (F1-2);
@@ -19686,7 +19685,7 @@ example is listed in Figure~\ref{fig:map-type-check}.
 \begin{figure}[tbp]
 \begin{lstlisting}[basicstyle=\ttfamily\scriptsize]
 (define type-check-poly-class
-  (class type-check-Rwhile-class
+  (class type-check-Lwhile-class
     (super-new)
     (inherit check-type-equal?)
   
@@ -20027,12 +20026,12 @@ annotations and the body.
 \node (Rpoly) at (9,4)  {\large \LangPoly{}};
 \node (Rpolyp) at (6,4)  {\large \LangInst{}};
 \node (Rgradualp) at (3,4)  {\large \LangCast{}};
-\node (Rwhilepp) at (0,4)  {\large \LangProxy{}};
-\node (Rwhileproxy) at (0,2)  {\large \LangPVec{}};
-\node (Rwhileproxy-2) at (3,2)  {\large \LangPVec{}};
-\node (Rwhileproxy-3) at (6,2)  {\large \LangPVec{}};
-\node (Rwhileproxy-4) at (9,2)  {\large \LangPVecFunRef{}};
-\node (Rwhileproxy-5) at (12,2)  {\large \LangPVecFunRef{}};
+\node (Lwhilepp) at (0,4)  {\large \LangProxy{}};
+\node (Lwhileproxy) at (0,2)  {\large \LangPVec{}};
+\node (Lwhileproxy-2) at (3,2)  {\large \LangPVec{}};
+\node (Lwhileproxy-3) at (6,2)  {\large \LangPVec{}};
+\node (Lwhileproxy-4) at (9,2)  {\large \LangPVecFunRef{}};
+\node (Lwhileproxy-5) at (12,2)  {\large \LangPVecFunRef{}};
 \node (F1-1) at (12,0)  {\large \LangPVecFunRef{}};
 \node (F1-2) at (9,0)  {\large \LangPVecFunRef{}};
 \node (F1-3) at (6,0)  {\large \LangPVecFunRef{}};
@@ -20053,18 +20052,18 @@ annotations and the body.
 \path[->,bend right=15] (Rpolyp) edge [above] node
      {\ttfamily\footnotesize erase\_types} (Rgradualp);
 \path[->,bend right=15] (Rgradualp) edge [above] node
-     {\ttfamily\footnotesize lower\_casts} (Rwhilepp);
-\path[->,bend right=15] (Rwhilepp) edge [right] node
-     {\ttfamily\footnotesize differentiate\_proxies} (Rwhileproxy);
-\path[->,bend left=15] (Rwhileproxy) edge [above] node
-     {\ttfamily\footnotesize shrink} (Rwhileproxy-2);
-\path[->,bend left=15] (Rwhileproxy-2) edge [above] node
-     {\ttfamily\footnotesize uniquify} (Rwhileproxy-3);
-\path[->,bend left=15] (Rwhileproxy-3) edge [above] node
-     {\ttfamily\footnotesize reveal\_functions} (Rwhileproxy-4);
-\path[->,bend left=15] (Rwhileproxy-4) edge [above] node
-     {\ttfamily\footnotesize reveal\_casts} (Rwhileproxy-5);
-\path[->,bend left=15] (Rwhileproxy-5) edge [left] node
+     {\ttfamily\footnotesize lower\_casts} (Lwhilepp);
+\path[->,bend right=15] (Lwhilepp) edge [right] node
+     {\ttfamily\footnotesize differentiate\_proxies} (Lwhileproxy);
+\path[->,bend left=15] (Lwhileproxy) edge [above] node
+     {\ttfamily\footnotesize shrink} (Lwhileproxy-2);
+\path[->,bend left=15] (Lwhileproxy-2) edge [above] node
+     {\ttfamily\footnotesize uniquify} (Lwhileproxy-3);
+\path[->,bend left=15] (Lwhileproxy-3) edge [above] node
+     {\ttfamily\footnotesize reveal\_functions} (Lwhileproxy-4);
+\path[->,bend left=15] (Lwhileproxy-4) edge [above] node
+     {\ttfamily\footnotesize reveal\_casts} (Lwhileproxy-5);
+\path[->,bend left=15] (Lwhileproxy-5) edge [left] node
      {\ttfamily\footnotesize convert\_assignments} (F1-1);
 \path[->,bend left=15] (F1-1) edge [below] node
      {\ttfamily\footnotesize convert\_to\_clos.} (F1-2);