Explorar o código

edits to ch 11

Jeremy G. Siek %!s(int64=2) %!d(string=hai) anos
pai
achega
6e4c776bb5
Modificáronse 1 ficheiros con 8 adicións e 6 borrados
  1. 8 6
      book.tex

+ 8 - 6
book.tex

@@ -20672,7 +20672,7 @@ print(t[1])
 {\if\edition\pythonEd\pythonColor        
 {\if\edition\pythonEd\pythonColor        
 \begin{figure}[tbp]
 \begin{figure}[tbp]
 \begin{tcolorbox}[colback=white]  
 \begin{tcolorbox}[colback=white]  
-\begin{lstlisting}[basicstyle=\ttfamily\footnotesize]
+\begin{lstlisting}
 class TypeCheckLgrad(TypeCheckLlambda):
 class TypeCheckLgrad(TypeCheckLlambda):
   def type_check_exp(self, e, env) -> Type:
   def type_check_exp(self, e, env) -> Type:
     match e:
     match e:
@@ -20701,14 +20701,16 @@ class TypeCheckLgrad(TypeCheckLlambda):
         func_t = self.type_check_exp(func, env)
         func_t = self.type_check_exp(func, env)
         args_t = [self.type_check_exp(arg, env) for arg in args]
         args_t = [self.type_check_exp(arg, env) for arg in args]
         match func_t:
         match func_t:
-          case FunctionType(params_t, return_t) if len(params_t) == len(args_t):
+          case FunctionType(params_t, return_t) \
+                if len(params_t) == len(args_t):
             for (arg_t, param_t) in zip(args_t, params_t):
             for (arg_t, param_t) in zip(args_t, params_t):
                 self.check_consistent(param_t, arg_t, e)
                 self.check_consistent(param_t, arg_t, e)
             return return_t
             return return_t
           case AnyType():
           case AnyType():
             return AnyType()
             return AnyType()
           case _:
           case _:
-            raise Exception('type_check_exp: in call, unexpected ' + repr(func_t))
+            raise Exception('type_check_exp: in call, unexpected '
+                              + repr(func_t))
       ...
       ...
       case _:
       case _:
         raise Exception('type_check_exp: unexpected ' + repr(e))
         raise Exception('type_check_exp: unexpected ' + repr(e))
@@ -21624,7 +21626,7 @@ backward! Functions are contravariant\index{subject}{contravariant}
 in the parameters.) Afterward, call the underlying function and then
 in the parameters.) Afterward, call the underlying function and then
 cast the result from the source return type to the target return type.
 cast the result from the source return type to the target return type.
 Figure~\ref{fig:map-lower-cast} shows the output of the
 Figure~\ref{fig:map-lower-cast} shows the output of the
-\code{lower\_casts} pass on the \code{map} example give in
+\code{lower\_casts} pass on the \code{map} example given in
 figure~\ref{fig:gradual-map}. Note that the \code{inc} argument in the
 figure~\ref{fig:gradual-map}. Note that the \code{inc} argument in the
 call to \code{map} is wrapped in a \code{lambda}.
 call to \code{map} is wrapped in a \code{lambda}.
 
 
@@ -21938,7 +21940,7 @@ the target type is \code{PVector}.  Instead of using
 Recall that the $\itm{tagof}$ function determines the bits used to
 Recall that the $\itm{tagof}$ function determines the bits used to
 identify values of different types, and it is used in the \code{reveal\_casts}
 identify values of different types, and it is used in the \code{reveal\_casts}
 pass in the translation of \code{Project}. The \PTUPLETYNAME{} and
 pass in the translation of \code{Project}. The \PTUPLETYNAME{} and
-\PARRAYTYNAME{} types can be mapped to $010$ in binary ($2$ is
+\PARRAYTYNAME{} types can be mapped to $010$ in binary ($2$ in
 decimal), just like the tuple and array types.
 decimal), just like the tuple and array types.
 \fi}  
 \fi}  
 %
 %
@@ -22303,7 +22305,7 @@ needed for the compilation of \LangGrad{}.
 
 
 This chapter just scratches the surface of gradual typing.  The basic
 This chapter just scratches the surface of gradual typing.  The basic
 approach described here is missing two key ingredients that one would
 approach described here is missing two key ingredients that one would
-want in a implementation of gradual typing: blame
+want in an implementation of gradual typing: blame
 tracking~\citep{Tobin-Hochstadt:2006fk,Wadler:2009qv} and
 tracking~\citep{Tobin-Hochstadt:2006fk,Wadler:2009qv} and
 space-efficient casts~\citep{Herman:2006uq,Herman:2010aa}.  The
 space-efficient casts~\citep{Herman:2006uq,Herman:2010aa}.  The
 problem addressed by blame tracking is that when a cast on a
 problem addressed by blame tracking is that when a cast on a