mirror of
https://github.com/dhil/phd-dissertation
synced 2026-04-30 16:06:29 +01:00
Compare commits
3 Commits
2800e2bd75
...
ca707ccac4
| Author | SHA1 | Date | |
|---|---|---|---|
| ca707ccac4 | |||
| ea9763fd70 | |||
| 293bdae1d3 |
@@ -150,7 +150,7 @@
|
|||||||
%%
|
%%
|
||||||
%% Labels
|
%% Labels
|
||||||
%%
|
%%
|
||||||
\newcommand{\slab}[1]{\textrm{#1}}
|
\newcommand{\slab}[1]{\ensuremath{\mathsf{#1}}}
|
||||||
\newcommand{\rulelabel}[2]{\ensuremath{\mathsf{#1\textrm{-}#2}}}
|
\newcommand{\rulelabel}[2]{\ensuremath{\mathsf{#1\textrm{-}#2}}}
|
||||||
\newcommand{\klab}[1]{\rulelabel{K}{#1}}
|
\newcommand{\klab}[1]{\rulelabel{K}{#1}}
|
||||||
\newcommand{\semlab}[1]{\rulelabel{S}{#1}}
|
\newcommand{\semlab}[1]{\rulelabel{S}{#1}}
|
||||||
@@ -440,8 +440,8 @@
|
|||||||
\newcommand{\fprompt}{\%}
|
\newcommand{\fprompt}{\%}
|
||||||
\newcommand{\splitter}{\keyw{splitter}}
|
\newcommand{\splitter}{\keyw{splitter}}
|
||||||
\newcommand{\J}{\keyw{J}}
|
\newcommand{\J}{\keyw{J}}
|
||||||
\newcommand{\FelleisenC}{\ensuremath{\mathcal{C}}}
|
\newcommand{\FelleisenC}{\ensuremath{\keyw{C}}}
|
||||||
\newcommand{\FelleisenF}{\ensuremath{\mathcal{F}}}
|
\newcommand{\FelleisenF}{\ensuremath{\keyw{F}}}
|
||||||
\newcommand{\cont}{\keyw{cont}}
|
\newcommand{\cont}{\keyw{cont}}
|
||||||
\newcommand{\Cont}{\dec{Cont}}
|
\newcommand{\Cont}{\dec{Cont}}
|
||||||
\newcommand{\Algol}{Algol~60}
|
\newcommand{\Algol}{Algol~60}
|
||||||
68
thesis.tex
68
thesis.tex
@@ -679,7 +679,7 @@ non-exhaustive list of first-class control operators.
|
|||||||
\hline
|
\hline
|
||||||
\multicolumn{1}{| l |}{\textbf{Name}} & \multicolumn{1}{l |}{\textbf{Extent}} & \multicolumn{1}{l |}{\textbf{Continuation behaviour}} & \multicolumn{1}{l |}{\textbf{Canonical reference}}\\
|
\multicolumn{1}{| l |}{\textbf{Name}} & \multicolumn{1}{l |}{\textbf{Extent}} & \multicolumn{1}{l |}{\textbf{Continuation behaviour}} & \multicolumn{1}{l |}{\textbf{Canonical reference}}\\
|
||||||
\hline
|
\hline
|
||||||
\FelleisenC & Undelimited & Abortive & \citet{FelleisenF86} \\
|
C & Undelimited & Abortive & \citet{FelleisenF86} \\
|
||||||
\hline
|
\hline
|
||||||
call/cc & Undelimited & Abortive & \citet{AbelsonHAKBOBPCRFRHSHW85} \\
|
call/cc & Undelimited & Abortive & \citet{AbelsonHAKBOBPCRFRHSHW85} \\
|
||||||
\hline
|
\hline
|
||||||
@@ -697,7 +697,7 @@ non-exhaustive list of first-class control operators.
|
|||||||
\hline
|
\hline
|
||||||
escape & Undelimited & Abortive & \citet{Reynolds98a}\\
|
escape & Undelimited & Abortive & \citet{Reynolds98a}\\
|
||||||
\hline
|
\hline
|
||||||
\FelleisenF & Undelimited & Composable & \citet{FelleisenFDM87}\\
|
F & Undelimited & Composable & \citet{FelleisenFDM87}\\
|
||||||
\hline
|
\hline
|
||||||
fcontrol & Delimited & Composable & \citet{Sitaram93} \\
|
fcontrol & Delimited & Composable & \citet{Sitaram93} \\
|
||||||
\hline
|
\hline
|
||||||
@@ -802,14 +802,22 @@ argument $V$ plugged in.
|
|||||||
|
|
||||||
\paragraph{Sussman and Steele's catch}
|
\paragraph{Sussman and Steele's catch}
|
||||||
%
|
%
|
||||||
The catch operator was introduced into the programming language Scheme
|
The catch operator originated in Lisp as an exception handling
|
||||||
by \citeauthor{SussmanS75} in 1975 as a mechanism for performing
|
construct. It had a companion throw operation, which would unwind the
|
||||||
non-local exits~\cite{SussmanS75}.
|
evaluation stack until it was caught by an instance of catch. In 1975
|
||||||
|
\citeauthor{SussmanS75} implemented a more powerful variation of the
|
||||||
|
catch operator in Scheme~\cite{SussmanS75}. Their catch operator would
|
||||||
|
disperse of the throw operation and instead provide the programmer
|
||||||
|
with access to the current continuation. Thus it is same as
|
||||||
|
\citeauthor{Reynolds98a}' escape operator.
|
||||||
%
|
%
|
||||||
\[
|
\[
|
||||||
M,N ::= \cdots \mid \Catch~k.M
|
M,N ::= \cdots \mid \Catch~k.M
|
||||||
\]
|
\]
|
||||||
%
|
%
|
||||||
|
Although, their syntax differ, their static and dynamic semantics are
|
||||||
|
the same.
|
||||||
|
%
|
||||||
\begin{mathpar}
|
\begin{mathpar}
|
||||||
\inferrule*
|
\inferrule*
|
||||||
{\typ{\Gamma,k : \Cont\,\Record{A;\Zero}}{M : A}}
|
{\typ{\Gamma,k : \Cont\,\Record{A;\Zero}}{M : A}}
|
||||||
@@ -825,11 +833,28 @@ non-local exits~\cite{SussmanS75}.
|
|||||||
\slab{Resume} & \EC[\Continue~\cont_{\EC'}~V] &\reducesto& \EC'[V]
|
\slab{Resume} & \EC[\Continue~\cont_{\EC'}~V] &\reducesto& \EC'[V]
|
||||||
\end{reductions}
|
\end{reductions}
|
||||||
%
|
%
|
||||||
As an aside it is worth mentioning that \citet{CartwrightF92} used a
|
As an aside it is worth to mention that \citet{CartwrightF92} used a
|
||||||
variation of $\Catch$ to show that programs can use control operators
|
variation of $\Catch$ to show that control operators enable programs
|
||||||
to observe the order of evaluation.
|
to observe the order of evaluation.
|
||||||
|
|
||||||
\paragraph{Call-with-current-continuation}
|
\paragraph{Call-with-current-continuation} In 1982 the Scheme
|
||||||
|
implementors observed that they could dispense of the special syntax
|
||||||
|
for $\Catch$ in favour of a higher-order function that would apply its
|
||||||
|
argument to the current continuation, and thus callcc was born (callcc
|
||||||
|
is short for
|
||||||
|
call-with-current-continuation)~\cite{AbelsonHAKBOBPCRFRHSHW85}.
|
||||||
|
%
|
||||||
|
|
||||||
|
Unlike the previous operators, callcc augments the syntactic
|
||||||
|
categories of values.
|
||||||
|
%
|
||||||
|
\[
|
||||||
|
V,W \in \ValCat ::= \cdots \mid \Callcc
|
||||||
|
\]
|
||||||
|
%
|
||||||
|
The value $\Callcc$ is essentially a hard-wired function name. The
|
||||||
|
typing rule for $\Callcc$ makes it clear that it is a particular
|
||||||
|
higher-order function.
|
||||||
%
|
%
|
||||||
\begin{mathpar}
|
\begin{mathpar}
|
||||||
\inferrule*
|
\inferrule*
|
||||||
@@ -841,11 +866,22 @@ to observe the order of evaluation.
|
|||||||
{\typ{\Gamma}{\Continue~W~V : \Zero}}
|
{\typ{\Gamma}{\Continue~W~V : \Zero}}
|
||||||
\end{mathpar}
|
\end{mathpar}
|
||||||
%
|
%
|
||||||
|
An invocation of $\Callcc$ returns a value of type $A$. This value can
|
||||||
|
be produced in one of two ways, either the function argument returns
|
||||||
|
normally or it applies the provided continuation object to a value
|
||||||
|
that then becomes the result of $\Callcc$-application.
|
||||||
|
%
|
||||||
\begin{reductions}
|
\begin{reductions}
|
||||||
\slab{Capture} & \EC[\Callcc~V] &\reducesto& \EC[V~\cont_{\EC}]\\
|
\slab{Capture} & \EC[\Callcc~V] &\reducesto& \EC[V~\cont_{\EC}]\\
|
||||||
\slab{Resume} & \EC[\Continue~\cont_{\EC'}~V] &\reducesto& \EC'[V]
|
\slab{Resume} & \EC[\Continue~\cont_{\EC'}~V] &\reducesto& \EC'[V]
|
||||||
\end{reductions}
|
\end{reductions}
|
||||||
%
|
%
|
||||||
|
From the dynamic semantics it is evident that $\Callcc$ is a
|
||||||
|
syntax-free alternative to $\Catch$, i.e.
|
||||||
|
%
|
||||||
|
\[
|
||||||
|
\sembr{\Catch~k.M} = \Callcc\,(\lambda k.M)
|
||||||
|
\]
|
||||||
|
|
||||||
\paragraph{Call-with-composable-continuation}
|
\paragraph{Call-with-composable-continuation}
|
||||||
call-with-composable-continuation (MzScheme 360, November 2006).
|
call-with-composable-continuation (MzScheme 360, November 2006).
|
||||||
@@ -1006,8 +1042,8 @@ annotate the evaluation contexts for ordinary applications.
|
|||||||
\slab{Resume} & \EC[\Continue~\cont_{\Record{\EC';W}}\,V] &\reducesto& \EC'[W\,V]
|
\slab{Resume} & \EC[\Continue~\cont_{\Record{\EC';W}}\,V] &\reducesto& \EC'[W\,V]
|
||||||
\end{reductions}
|
\end{reductions}
|
||||||
%
|
%
|
||||||
$\slab{Capture}$ rule only applies if the application of $\J$ takes
|
The $\slab{Capture}$ rule only applies if the application of $\J$
|
||||||
place in annotated evaluation context. The continuation object
|
takes place in annotated evaluation context. The continuation object
|
||||||
produced by a $\J$ application encompasses the caller's continuation
|
produced by a $\J$ application encompasses the caller's continuation
|
||||||
$\EC_\lambda$ and the value argument $W$.
|
$\EC_\lambda$ and the value argument $W$.
|
||||||
%
|
%
|
||||||
@@ -1047,6 +1083,8 @@ undelimited control~\cite{Filinski94}
|
|||||||
|
|
||||||
\paragraph{Control/prompt}
|
\paragraph{Control/prompt}
|
||||||
%
|
%
|
||||||
|
The operator control is a rebranding of Felleisen's F operator.
|
||||||
|
%
|
||||||
\begin{reductions}
|
\begin{reductions}
|
||||||
\slab{Value} &
|
\slab{Value} &
|
||||||
\Prompt~V &\reducesto& V\\
|
\Prompt~V &\reducesto& V\\
|
||||||
@@ -1115,9 +1153,9 @@ undelimited control~\cite{Filinski94}
|
|||||||
%
|
%
|
||||||
\begin{reductions}
|
\begin{reductions}
|
||||||
\slab{Value} & \reset{V} &\reducesto& V\\
|
\slab{Value} & \reset{V} &\reducesto& V\\
|
||||||
\slab{Capture} & \reset{\EC[\shift\,k.M]} &\reducesto& \reset{M[\cont_{\reset{\EC}}/k]}, \text { where $\EC$ contains no $\reset{-}$}\\
|
\slab{Capture} & \reset{\EC[\shift\,k.M]} &\reducesto& \reset{M[\cont_{\EC}/k]}, \text { where $\EC$ contains no $\reset{-}$}\\
|
||||||
% \slab{Resume} & \reset{\EC[\Continue~\cont_{\reset{\EC'}}~V]} &\reducesto& \reset{\EC[\reset{\EC'[V]}]}\\
|
% \slab{Resume} & \reset{\EC[\Continue~\cont_{\reset{\EC'}}~V]} &\reducesto& \reset{\EC[\reset{\EC'[V]}]}\\
|
||||||
\slab{Resume} & \Continue~\cont_{\reset{\EC}}~V &\reducesto& \reset{\EC[V]}\\
|
\slab{Resume} & \Continue~\cont_{\EC}~V &\reducesto& \reset{\EC[V]}\\
|
||||||
\end{reductions}
|
\end{reductions}
|
||||||
%
|
%
|
||||||
|
|
||||||
@@ -1131,9 +1169,9 @@ undelimited control~\cite{Filinski94}
|
|||||||
|
|
||||||
\paragraph{Splitter}
|
\paragraph{Splitter}
|
||||||
\begin{reductions}
|
\begin{reductions}
|
||||||
\slab{Throw} & \splitter~f~g.\EC[\,f~V] &\reducesto& V~\Unit\\
|
\slab{Throw} & \splitter~throw~callpc.\EC[\,throw~V] &\reducesto& V~\Unit\\
|
||||||
\slab{Capture} &
|
\slab{Capture} &
|
||||||
\splitter~f~g.\EC[g~V] &\reducesto& V~\cont_{\EC} \\
|
\splitter~throw~callpc.\EC[callpc~V] &\reducesto& V~\cont_{\EC} \\
|
||||||
\slab{Resume} & \Continue~\cont_{\EC}~V &\reducesto& \EC[V]
|
\slab{Resume} & \Continue~\cont_{\EC}~V &\reducesto& \EC[V]
|
||||||
\end{reductions}
|
\end{reductions}
|
||||||
|
|
||||||
@@ -1156,7 +1194,7 @@ For example callec is a variation of callcc where the continuation
|
|||||||
only can be invoked during the dynamic extent of
|
only can be invoked during the dynamic extent of
|
||||||
callec~\cite{Flatt20}.
|
callec~\cite{Flatt20}.
|
||||||
|
|
||||||
\section{Implementation strategies for first-class control}
|
\section{Implementing continuations}
|
||||||
Table~\ref{tbl:ctrl-operators-impls} lists some programming languages
|
Table~\ref{tbl:ctrl-operators-impls} lists some programming languages
|
||||||
with support for first-class control operators and their
|
with support for first-class control operators and their
|
||||||
implementation strategies.
|
implementation strategies.
|
||||||
|
|||||||
Reference in New Issue
Block a user