|
@@ -22655,7 +22655,6 @@ replaced by the deduced type arguments, using the
|
|
\code{substitute\_type} auxiliary function, which is also listed in
|
|
\code{substitute\_type} auxiliary function, which is also listed in
|
|
figure~\ref{fig:type-check-Lpoly-aux}.
|
|
figure~\ref{fig:type-check-Lpoly-aux}.
|
|
|
|
|
|
-
|
|
|
|
The type checker extends type equality to handle the \code{All} type.
|
|
The type checker extends type equality to handle the \code{All} type.
|
|
This is not quite as simple as for other types, such as function and
|
|
This is not quite as simple as for other types, such as function and
|
|
tuple types, because two \code{All} types can be syntactically
|
|
tuple types, because two \code{All} types can be syntactically
|
|
@@ -23167,7 +23166,7 @@ We use the \CANYTY{} type presented in chapter~\ref{ch:Ldyn} to
|
|
represent type variables. For example, figure~\ref{fig:map-erase}
|
|
represent type variables. For example, figure~\ref{fig:map-erase}
|
|
shows the output of the \code{erase\_types} pass on the generic
|
|
shows the output of the \code{erase\_types} pass on the generic
|
|
\code{map} (figure~\ref{fig:map-poly}). The occurrences of
|
|
\code{map} (figure~\ref{fig:map-poly}). The occurrences of
|
|
-type parameter \code{a} are replaced by \CANYTY{}, and the generic
|
|
|
|
|
|
+type parameter \code{T} are replaced by \CANYTY{}, and the generic
|
|
\code{All} types are removed from the type of \code{map}.
|
|
\code{All} types are removed from the type of \code{map}.
|
|
|
|
|
|
\begin{figure}[tbp]
|
|
\begin{figure}[tbp]
|
|
@@ -23228,7 +23227,7 @@ All[[T], Callable[[Callable[[T], T], tuple[T, T]], tuple[T, T]]]
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
%
|
|
%
|
|
-and it is instantiated to
|
|
|
|
|
|
+\noindent and it is instantiated to
|
|
%
|
|
%
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\begin{lstlisting}
|
|
\begin{lstlisting}
|
|
@@ -23242,7 +23241,7 @@ Callable[[Callable[[int], int], tuple[int, int]], tuple[int, int]]
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
%
|
|
%
|
|
-After erasure, the type of \code{map} is
|
|
|
|
|
|
+\noindent After erasure, the type of \code{map} is
|
|
%
|
|
%
|
|
{\if\edition\racketEd
|
|
{\if\edition\racketEd
|
|
\begin{lstlisting}
|
|
\begin{lstlisting}
|
|
@@ -23255,14 +23254,14 @@ Callable[[Callable[[Any], Any], tuple[Any, Any]], tuple[Any, Any]]
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
%
|
|
%
|
|
-but we need to convert it to the instantiated type. This is easy to
|
|
|
|
-do in the language \LangCast{} with a single \code{cast}. In the
|
|
|
|
-example shown in figure~\ref{fig:map-erase}, the instantiation of
|
|
|
|
|
|
+\noindent but we need to convert it to the instantiated type. This is
|
|
|
|
+easy to do in the language \LangCast{} with a single \code{cast}. In
|
|
|
|
+the example shown in figure~\ref{fig:map-erase}, the instantiation of
|
|
\code{map} has been compiled to a \code{cast} from the type of
|
|
\code{map} has been compiled to a \code{cast} from the type of
|
|
-\code{map} to the instantiated type. The source and the target type of a
|
|
|
|
-cast must be consistent (figure~\ref{fig:consistent}), which indeed is
|
|
|
|
-the case because both the source and target are obtained from the same
|
|
|
|
-generic type of \code{map}, replacing the type parameters with
|
|
|
|
|
|
+\code{map} to the instantiated type. The source and the target type of
|
|
|
|
+a cast must be consistent (figure~\ref{fig:consistent}), which indeed
|
|
|
|
+is the case because both the source and target are obtained from the
|
|
|
|
+same generic type of \code{map}, replacing the type parameters with
|
|
\CANYTY{} in the former and with the deduced type arguments in the
|
|
\CANYTY{} in the former and with the deduced type arguments in the
|
|
latter. (Recall that the \CANYTY{} type is consistent with any type.)
|
|
latter. (Recall that the \CANYTY{} type is consistent with any type.)
|
|
|
|
|
|
@@ -23303,7 +23302,8 @@ AllType(|$xs$|, |$T_1$|)
|
|
|$T'_1$|
|
|
|$T'_1$|
|
|
\end{lstlisting}
|
|
\end{lstlisting}
|
|
\fi}
|
|
\fi}
|
|
-where $T'_1$ is the result of applying \code{erase\_type} to $T_1$.
|
|
|
|
|
|
+\noindent where $T'_1$ is the result of applying \code{erase\_type} to
|
|
|
|
+$T_1$.
|
|
%
|
|
%
|
|
In this compiler pass, apply the \code{erase\_type} function to all
|
|
In this compiler pass, apply the \code{erase\_type} function to all
|
|
the type annotations in the program.
|
|
the type annotations in the program.
|