| 1 | \chapter{Introduction}
 | 
|---|
| 2 | 
 | 
|---|
| 3 | \PAB{Stay in the present tense. \newline
 | 
|---|
| 4 | \url{https://plg.uwaterloo.ca/~pabuhr/technicalWriting.shtml}}
 | 
|---|
| 5 | \newline
 | 
|---|
| 6 | \PAB{Note, \lstinline{lstlisting} normally bolds keywords. None of the keywords in your thesis are bolded.}
 | 
|---|
| 7 | 
 | 
|---|
| 8 | % Talk about Cforall and exceptions generally.
 | 
|---|
| 9 | %This thesis goes over the design and implementation of the exception handling
 | 
|---|
| 10 | %mechanism (EHM) of
 | 
|---|
| 11 | %\CFA (pernounced sea-for-all and may be written Cforall or CFA).
 | 
|---|
| 12 | Exception handling provides alternative dynamic inter-function control flow.
 | 
|---|
| 13 | There are two forms of exception handling covered in this thesis:
 | 
|---|
| 14 | termination, which acts as a multi-level return,
 | 
|---|
| 15 | and resumption, which is a dynamic function call.
 | 
|---|
| 16 | Note, termination exception handling is so common it is often assumed to be the only form.
 | 
|---|
| 17 | Lesser know derivations of inter-function control flow are continuation passing in Lisp~\cite{CommonLisp}.
 | 
|---|
| 18 | 
 | 
|---|
| 19 | Termination exception handling allows control to return to any previous
 | 
|---|
| 20 | function on the stack directly, skipping any functions between it and the
 | 
|---|
| 21 | current function.
 | 
|---|
| 22 | \begin{center}
 | 
|---|
| 23 | \input{callreturn}
 | 
|---|
| 24 | \end{center}
 | 
|---|
| 25 | 
 | 
|---|
| 26 | Resumption exception handling calls a function, but asks the functions on the
 | 
|---|
| 27 | stack what function that is.
 | 
|---|
| 28 | \todo{Add a diagram showing control flow for resumption.}
 | 
|---|
| 29 | 
 | 
|---|
| 30 | Although a powerful feature, exception handling tends to be complex to set up
 | 
|---|
| 31 | and expensive to use
 | 
|---|
| 32 | so they are often limited to unusual or ``exceptional" cases.
 | 
|---|
| 33 | The classic example of this is error handling, exceptions can be used to
 | 
|---|
| 34 | remove error handling logic from the main execution path and while paying
 | 
|---|
| 35 | most of the cost only when the error actually occurs.
 | 
|---|
| 36 | 
 | 
|---|
| 37 | % Overview of exceptions in Cforall.
 | 
|---|
| 38 | 
 | 
|---|
| 39 | \PAB{You need section titles here. Don't take them out.}
 | 
|---|
| 40 | 
 | 
|---|
| 41 | \section{Thesis Overview}
 | 
|---|
| 42 | 
 | 
|---|
| 43 | This thesis goes over the design and implementation of the exception handling
 | 
|---|
| 44 | mechanism (EHM) of
 | 
|---|
| 45 | \CFA (pernounced sea-for-all and may be written Cforall or CFA).
 | 
|---|
| 46 | %This thesis describes the design and implementation of the \CFA EHM.
 | 
|---|
| 47 | The \CFA EHM implements all of the common exception features (or an
 | 
|---|
| 48 | equivalent) found in most other EHMs and adds some features of its own.
 | 
|---|
| 49 | The design of all the features had to be adapted to \CFA's feature set as
 | 
|---|
| 50 | some of the underlying tools used to implement and express exception handling
 | 
|---|
| 51 | in other languages are absent in \CFA.
 | 
|---|
| 52 | Still the resulting syntax resembles that of other languages:
 | 
|---|
| 53 | \begin{cfa}
 | 
|---|
| 54 | try {
 | 
|---|
| 55 |         ...
 | 
|---|
| 56 |         T * object = malloc(request_size);
 | 
|---|
| 57 |         if (!object) {
 | 
|---|
| 58 |                 throw OutOfMemory{fixed_allocation, request_size};
 | 
|---|
| 59 |         }
 | 
|---|
| 60 |         ...
 | 
|---|
| 61 | } catch (OutOfMemory * error) {
 | 
|---|
| 62 |         ...
 | 
|---|
| 63 | }
 | 
|---|
| 64 | \end{cfa}
 | 
|---|
| 65 | 
 | 
|---|
| 66 | % A note that yes, that was a very fast overview.
 | 
|---|
| 67 | The design and implementation of all of \CFA's EHM's features are
 | 
|---|
| 68 | described in detail throughout this thesis, whether they are a common feature
 | 
|---|
| 69 | or one unique to \CFA.
 | 
|---|
| 70 | 
 | 
|---|
| 71 | % The current state of the project and what it contributes.
 | 
|---|
| 72 | All of these features have been implemented in \CFA, along with
 | 
|---|
| 73 | a suite of test cases as part of this project.
 | 
|---|
| 74 | The implementation techniques are generally applicable in other programming
 | 
|---|
| 75 | languages and much of the design is as well.
 | 
|---|
| 76 | Some parts of the EHM use other features unique to \CFA and these would be
 | 
|---|
| 77 | harder to replicate in other programming languages.
 | 
|---|
| 78 | 
 | 
|---|
| 79 | \section{Background}
 | 
|---|
| 80 | 
 | 
|---|
| 81 | % Talk about other programming languages.
 | 
|---|
| 82 | Some existing programming languages that include EHMs/exception handling
 | 
|---|
| 83 | include C++, Java and Python. All three examples focus on termination
 | 
|---|
| 84 | exceptions which unwind the stack as part of the
 | 
|---|
| 85 | Exceptions also can replace return codes and return unions.
 | 
|---|
| 86 | In functional languages will also sometimes fold exceptions into monads.
 | 
|---|
| 87 | 
 | 
|---|
| 88 | \PAB{You must demonstrate knowledge of background material here.
 | 
|---|
| 89 | It should be at least a full page.}
 | 
|---|
| 90 | 
 | 
|---|
| 91 | \section{Contributions}
 | 
|---|
| 92 | 
 | 
|---|
| 93 | The contributions of this work are:
 | 
|---|
| 94 | \begin{enumerate}
 | 
|---|
| 95 | \item Designing \CFA's exception handling mechanism, adapting designs from
 | 
|---|
| 96 | other programming languages and the creation of new features.
 | 
|---|
| 97 | \item Implementing stack unwinding and the EHM in \CFA, including updating
 | 
|---|
| 98 | the compiler and the run-time environment.
 | 
|---|
| 99 | \item Designed and implemented a prototype virtual system.
 | 
|---|
| 100 | % I think the virtual system and per-call site default handlers are the only
 | 
|---|
| 101 | % "new" features, everything else is a matter of implementation.
 | 
|---|
| 102 | \end{enumerate}
 | 
|---|
| 103 | 
 | 
|---|
| 104 | \todo{I can't figure out a good lead-in to the overview.}
 | 
|---|
| 105 | Covering the existing \CFA features in \autoref{c:existing}.
 | 
|---|
| 106 | Then the new features are introduce in \autoref{c:features}, explaining their
 | 
|---|
| 107 | usage and design.
 | 
|---|
| 108 | That is followed by the implementation of those features in
 | 
|---|
| 109 | \autoref{c:implement}.
 | 
|---|
| 110 | % Future Work \autoref{c:future}
 | 
|---|