mirror of
https://github.com/dhil/phd-dissertation
synced 2026-03-13 11:08:25 +00:00
Code for non-local exits
This commit is contained in:
@@ -330,7 +330,10 @@
|
|||||||
|
|
||||||
% UNIX example
|
% UNIX example
|
||||||
\newcommand{\OSname}[0]{Tiny UNIX}
|
\newcommand{\OSname}[0]{Tiny UNIX}
|
||||||
\newcommand{\Uexit}{\dec{exit}}
|
\newcommand{\exit}{\dec{exit}}
|
||||||
|
\newcommand{\Exit}{\dec{Exit}}
|
||||||
|
\newcommand{\Status}{\dec{Status}}
|
||||||
|
\newcommand{\status}{\dec{status}}
|
||||||
\newcommand{\basicIO}{\dec{basicIO}}
|
\newcommand{\basicIO}{\dec{basicIO}}
|
||||||
\newcommand{\Putc}{\dec{Putc}}
|
\newcommand{\Putc}{\dec{Putc}}
|
||||||
\newcommand{\putc}{\dec{putc}}
|
\newcommand{\putc}{\dec{putc}}
|
||||||
|
|||||||
36
thesis.tex
36
thesis.tex
@@ -2121,6 +2121,42 @@ We can now write some contents to the file and observe the effects.
|
|||||||
\subsection{Exceptions: non-local exits}
|
\subsection{Exceptions: non-local exits}
|
||||||
\label{sec:tiny-unix-exit}
|
\label{sec:tiny-unix-exit}
|
||||||
|
|
||||||
|
\[
|
||||||
|
\Status \defas \{\Exit : \Int \opto \Zero\}
|
||||||
|
\]
|
||||||
|
|
||||||
|
\[
|
||||||
|
\bl
|
||||||
|
\exit : \Int \to \alpha \eff \Status\\
|
||||||
|
\exit~n \defas \Absurd\;(\Do\;\Exit~n)
|
||||||
|
\el
|
||||||
|
\]
|
||||||
|
|
||||||
|
\[
|
||||||
|
\bl
|
||||||
|
\status : (\UnitType \to \alpha \eff \Status) \to \Int\\
|
||||||
|
\status~m \defas
|
||||||
|
\ba[t]{@{~}l}
|
||||||
|
\Handle\;m\,\Unit\;\With\\
|
||||||
|
~\ba{@{~}l@{~}c@{~}l}
|
||||||
|
\Return\;\_ &\mapsto& 0\\
|
||||||
|
\Exit~n~\_ &\mapsto& n
|
||||||
|
\ea
|
||||||
|
\ea
|
||||||
|
\el
|
||||||
|
\]
|
||||||
|
|
||||||
|
\[
|
||||||
|
\ba{@{~}l@{~}l}
|
||||||
|
&\bl
|
||||||
|
\basicIO\,(\lambda\Unit.
|
||||||
|
\status\,(\lambda\Unit.
|
||||||
|
\fwrite\,\Record{\stdout;\texttt{"dead"}};\exit~1;\fwrite\,\Record{\stdout;\texttt{"code"}}))
|
||||||
|
\el\\
|
||||||
|
\reducesto^+& \Record{1;\texttt{"dead"}} : \Record{\Int;\UFile}
|
||||||
|
\ea
|
||||||
|
\]
|
||||||
|
|
||||||
\subsection{Dynamic binding: user-specific environments}
|
\subsection{Dynamic binding: user-specific environments}
|
||||||
\label{sec:tiny-unix-env}
|
\label{sec:tiny-unix-env}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user