Commit b86b4001 authored by Giuseppe Castagna's avatar Giuseppe Castagna
Browse files

small modifications

parent c16eb9e5
...@@ -375,7 +375,7 @@ most important ones can be summarized as follows: ...@@ -375,7 +375,7 @@ most important ones can be summarized as follows:
whether the type deduced for the result of the expression is either whether the type deduced for the result of the expression is either
$\Int{\to}\Int$ or $3{\to}3$ (which are both valid but incomparable). $\Int{\to}\Int$ or $3{\to}3$ (which are both valid but incomparable).
\item For gradually-typed languages it would yield an unsound system as \item For gradually-typed languages it would yield a problematic system as
we explain in Section~\ref{sec:gradual}. we explain in Section~\ref{sec:gradual}.
\end{enumerate} \end{enumerate}
Now, if we apply this restriction to the language of Now, if we apply this restriction to the language of
......
...@@ -14,7 +14,7 @@ of any study in this sense. We study it for the formalism of Section~\ref{sec:la ...@@ -14,7 +14,7 @@ of any study in this sense. We study it for the formalism of Section~\ref{sec:la
In a sense, occurrence typing is a In a sense, occurrence typing is a
discipline designed to push forward the frontiers beyond which gradual discipline designed to push forward the frontiers beyond which gradual
typing is needed, thus reducing the amount of runtime checks needed. For typing is needed, thus reducing the amount of runtime checks needed. For
instance, the the JavaScript code of~\eqref{foo} and~\eqref{foo2} in the introduction can be instance, the JavaScript code of~\eqref{foo} and~\eqref{foo2} in the introduction can also be
typed by using gradual typing:\vspace{-.4mm} typed by using gradual typing:\vspace{-.4mm}
\begin{alltt}\color{darkblue}\morecompact \begin{alltt}\color{darkblue}\morecompact
function foo(x\textcolor{darkred}{ : \pmb{\dyn}}) \{ function foo(x\textcolor{darkred}{ : \pmb{\dyn}}) \{
...@@ -32,11 +32,11 @@ where {\Cast{$t$}{$e$}} is a type-cast that dynamically checks whether the value ...@@ -32,11 +32,11 @@ where {\Cast{$t$}{$e$}} is a type-cast that dynamically checks whether the value
error")}. Not exactly though, since to implement compilation \emph{à la} sound gradual typing it is necessary to use casts on function types that need special handling.} error")}. Not exactly though, since to implement compilation \emph{à la} sound gradual typing it is necessary to use casts on function types that need special handling.}
% %
We already saw that thanks to occurrence typing we can annotate the parameter \code{x} by \code{number|string} instead of \dyn{} and avoid the insertion of any cast. We already saw that thanks to occurrence typing we can annotate the parameter \code{x} by \code{number|string} instead of \dyn{} and avoid the insertion of any cast.
But occurrence typing can be used also on the gradually typed code in order to statically detect the insertion of useless casts. Using But occurrence typing can be used also on the gradually typed code above in order to statically detect the insertion of useless casts. Using
occurrence typing to type the gradually-typed version of \code{foo} in~\eqref{foo3}, allows the system to avoid inserting the first cast occurrence typing to type the gradually-typed version of \code{foo} in~\eqref{foo3}, allows the system to avoid inserting the first cast
\code{\Cast{number}{x}} since, thanks to occurrence typing, the \code{\Cast{number}{x}} since, thanks to occurrence typing, the
occurrence of \code{x} at issue is given type \code{number} (the occurrence of \code{x} at issue is given type \code{number} (but the
second cast is still necessary however). But removing only this cast is far second cast is still necessary though). But removing only this cast is far
from being satisfactory, since when this function is applied to an integer from being satisfactory, since when this function is applied to an integer
there are some casts that still need to be inserted outside the function. there are some casts that still need to be inserted outside the function.
The reason is that the compiled version of the function The reason is that the compiled version of the function
......
...@@ -437,7 +437,7 @@ available online. ...@@ -437,7 +437,7 @@ available online.
of current approaches which require both the tests and the refinement of current approaches which require both the tests and the refinement
to take place on variables. to take place on variables.
\item We define a type-theoretic approach that is alternative to the \item We define a type-theoretic approach alternative to the
current flow-based approaches. As such it provides different current flow-based approaches. As such it provides different
results and it can be thus profitably combined with flow-based techniques. results and it can be thus profitably combined with flow-based techniques.
...@@ -454,8 +454,8 @@ available online. ...@@ -454,8 +454,8 @@ available online.
gradual typing and apply our results to optimze the compilation of the gradual typing and apply our results to optimze the compilation of the
latter. latter.
\item We show how it is possible to extend our framework to % \item We show how it is possible to extend our framework to
exploit the richer information provided by polymorphic types. % exploit the richer information provided by polymorphic types.
\end{itemize} \end{itemize}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment