Przeglądaj źródła

a little more progress

Jeremy Siek 3 lat temu
rodzic
commit
f47878274a
1 zmienionych plików z 34 dodań i 4 usunięć
  1. 34 4
      book.tex

+ 34 - 4
book.tex

@@ -21126,9 +21126,9 @@ variables.
 
 By including the \code{All} type in the $\Type$ non-terminal of the
 grammar we choose to make generics first-class, which has interesting
-repercussions on the compiler.\footnote{The Python typing library does
-  not include the \code{All} type, we are taking the liberty to add
-  the \code{All} type.}  Many languages with generics, such as
+repercussions on the compiler.\footnote{The Python \code{typing} library does
+not include syntax for the \code{All} type. It is inferred for functions whose
+type annotations contain type variables.}  Many languages with generics, such as
 C++~\citep{stroustrup88:_param_types} and Standard
 ML~\citep{Milner:1990fk}, only support second-class generics, so it
 may be helpful to see an example of first-class generics in action. In
@@ -21257,6 +21257,7 @@ example is listed in Figure~\ref{fig:map-type-check}.
 \begin{figure}[tbp]
   % poly_test_2.rkt
 \begin{tcolorbox}[colback=white]  
+\if\edition\racketEd    
 \begin{lstlisting}
 (poly (a) (define (map [f : (a -> a)] [v : (Vector a a)]) : (Vector a a)
   (vector (f (vector-ref v 0)) (f (vector-ref v 1)))))
@@ -21267,13 +21268,18 @@ example is listed in Figure~\ref{fig:map-type-check}.
                            (Integer))
               inc (vector 0 41)) 1)
 \end{lstlisting}
+\fi
+\if\edition\pythonEd
+UNDER CONSTRUCTION
+\fi
 \end{tcolorbox}
 \caption{Output of the type checker on the \code{map} example.}
 \label{fig:map-type-check}
 \end{figure}
 
 \begin{figure}[tbp]
-\begin{tcolorbox}[colback=white]  
+  \begin{tcolorbox}[colback=white]
+\if\edition\racketEd    
 \begin{lstlisting}[basicstyle=\ttfamily\scriptsize]
 (define type-check-poly-class
   (class type-check-Llambda-class
@@ -21340,6 +21346,10 @@ example is listed in Figure~\ref{fig:map-type-check}.
          (ProgramDefsExp info ds^^ body^)]))
   ))
 \end{lstlisting}
+\fi
+\if\edition\pythonEd
+UNDER CONSTRUCTION
+\fi
 \end{tcolorbox}
 
 \caption{Type checker for the \LangPoly{} language.}
@@ -21348,6 +21358,7 @@ example is listed in Figure~\ref{fig:map-type-check}.
 
 \begin{figure}[tbp]
 \begin{tcolorbox}[colback=white]  
+\if\edition\racketEd    
 \begin{lstlisting}[basicstyle=\ttfamily\scriptsize]
 (define/override (type-equal? t1 t2)
   (match* (t1 t2)
@@ -21409,6 +21420,10 @@ example is listed in Figure~\ref{fig:map-type-check}.
     [`(,(Def f params rt info body) . ,ds^)
      (cons (Def f params rt info body) (combine-decls-defs ds^))]))
 \end{lstlisting}
+\fi
+\if\edition\pythonEd
+UNDER CONSTRUCTION
+\fi
 \end{tcolorbox}
 
 \caption{Auxiliary functions for type checking \LangPoly{}.}
@@ -21418,6 +21433,7 @@ example is listed in Figure~\ref{fig:map-type-check}.
 
 \begin{figure}[tbp]
 \begin{tcolorbox}[colback=white]  
+\if\edition\racketEd    
 \begin{lstlisting}%[basicstyle=\ttfamily\scriptsize]
 (define/public ((check-well-formed env) ty)
   (match ty
@@ -21438,6 +21454,10 @@ example is listed in Figure~\ref{fig:map-type-check}.
      ((check-well-formed env^) t)]
     [else (error 'type-check "unrecognized type ~a" ty)]))
 \end{lstlisting}
+\fi
+\if\edition\pythonEd
+UNDER CONSTRUCTION
+\fi
 \end{tcolorbox}
 
 \caption{Well-formed types.}
@@ -21529,6 +21549,7 @@ type parameter \code{a} are replaced by \CANYTY{} and the polymorphic
 
 \begin{figure}[tbp]
 \begin{tcolorbox}[colback=white]  
+\if\edition\racketEd    
 \begin{lstlisting}
 (define (map [f : (Any -> Any)] [v : (Vector Any Any)])
                    : (Vector Any Any)
@@ -21542,6 +21563,10 @@ type parameter \code{a} are replaced by \CANYTY{} and the polymorphic
                                -> (Vector Integer Integer)))
              inc (vector 0 41)) 1)
 \end{lstlisting}
+\fi
+\if\edition\pythonEd
+UNDER CONSTRUCTION
+\fi
 \end{tcolorbox}
 
 \caption{The polymorphic \code{map} example after type erasure.}
@@ -21626,6 +21651,7 @@ annotations and the body.
 
 \begin{figure}[p]
 \begin{tcolorbox}[colback=white]  
+\if\edition\racketEd    
 \begin{tikzpicture}[baseline=(current  bounding  box.center),scale=0.85]
 \node (Lpoly) at (12,4)  {\large \LangPoly{}};
 \node (Lpolyp) at (9,4)  {\large \LangInst{}};
@@ -21694,6 +21720,10 @@ annotations and the body.
      {\ttfamily\footnotesize patch\_instr.} (x86-4);
 \path[->,bend left=15] (x86-4) edge [right] node {\ttfamily\footnotesize prelude\_and\_conc.} (x86-5);
 \end{tikzpicture}
+\fi
+\if\edition\pythonEd
+UNDER CONSTRUCTION
+\fi
 \end{tcolorbox}
 
 \caption{Diagram of the passes for \LangPoly{} (parametric polymorphism).}