\chapter{Introduction} \PAB{Stay in the present tense. \newline \url{https://plg.uwaterloo.ca/~pabuhr/technicalWriting.shtml}} \newline \PAB{Note, \lstinline{lstlisting} normally bolds keywords. None of the keywords in your thesis are bolded.} % Talk about Cforall and exceptions generally. %This thesis goes over the design and implementation of the exception handling %mechanism (EHM) of %\CFA (pernounced sea-for-all and may be written Cforall or CFA). Exception handling provides alternative dynamic inter-function control flow. There are two forms of exception handling covered in this thesis: termination, which acts as a multi-level return, and resumption, which is a dynamic function call. Note, termination exception handling is so common it is often assumed to be the only form. Lesser know derivations of inter-function control flow are continuation passing in Lisp~\cite{CommonLisp}. Termination exception handling allows control to return to any previous function on the stack directly, skipping any functions between it and the current function. \begin{center} \input{callreturn} \end{center} Resumption exception handling calls a function, but asks the functions on the stack what function that is. \todo{Add a diagram showing control flow for resumption.} Although a powerful feature, exception handling tends to be complex to set up and expensive to use so they are often limited to unusual or ``exceptional" cases. The classic example of this is error handling, exceptions can be used to remove error handling logic from the main execution path and while paying most of the cost only when the error actually occurs. % Overview of exceptions in Cforall. \PAB{You need section titles here. Don't take them out.} \section{Thesis Overview} This thesis goes over the design and implementation of the exception handling mechanism (EHM) of \CFA (pernounced sea-for-all and may be written Cforall or CFA). %This thesis describes the design and implementation of the \CFA EHM. The \CFA EHM implements all of the common exception features (or an equivalent) found in most other EHMs and adds some features of its own. The design of all the features had to be adapted to \CFA's feature set as some of the underlying tools used to implement and express exception handling in other languages are absent in \CFA. Still the resulting syntax resembles that of other languages: \begin{cfa} try { ... T * object = malloc(request_size); if (!object) { throw OutOfMemory{fixed_allocation, request_size}; } ... } catch (OutOfMemory * error) { ... } \end{cfa} % A note that yes, that was a very fast overview. The design and implementation of all of \CFA's EHM's features are described in detail throughout this thesis, whether they are a common feature or one unique to \CFA. % The current state of the project and what it contributes. All of these features have been implemented in \CFA, along with a suite of test cases as part of this project. The implementation techniques are generally applicable in other programming languages and much of the design is as well. Some parts of the EHM use other features unique to \CFA and these would be harder to replicate in other programming languages. \section{Background} % Talk about other programming languages. Some existing programming languages that include EHMs/exception handling include C++, Java and Python. All three examples focus on termination exceptions which unwind the stack as part of the Exceptions also can replace return codes and return unions. In functional languages will also sometimes fold exceptions into monads. \PAB{You must demonstrate knowledge of background material here. It should be at least a full page.} \section{Contributions} The contributions of this work are: \begin{enumerate} \item Designing \CFA's exception handling mechanism, adapting designs from other programming languages and the creation of new features. \item Implementing stack unwinding and the EHM in \CFA, including updating the compiler and the run-time environment. \item Designed and implemented a prototype virtual system. % I think the virtual system and per-call site default handlers are the only % "new" features, everything else is a matter of implementation. \end{enumerate} \todo{I can't figure out a good lead-in to the overview.} Covering the existing \CFA features in \autoref{c:existing}. Then the new features are introduce in \autoref{c:features}, explaining their usage and design. That is followed by the implementation of those features in \autoref{c:implement}. % Future Work \autoref{c:future}