Index: doc/theses/andrew_beach_MMath/existing.tex
===================================================================
--- doc/theses/andrew_beach_MMath/existing.tex	(revision d435c04cb8fd918cf352e0f7d2c50b5252396c26)
+++ doc/theses/andrew_beach_MMath/existing.tex	(revision f28fdee903fa756068b5401d0fcf0c910d9ade16)
@@ -1,7 +1,10 @@
-\chapter{\CFA{} Existing Features}
+\chapter{\CFA Existing Features}
+
+\CFA (C-for-all)~\cite{Cforall} is an open-source project extending ISO C with modern safety and productivity features, while still ensuring backwards compatibility with C and its programmers.
+\CFA is designed to have an orthogonal feature-set based closely on the C programming paradigm (non-object-oriented) and these features can be added incrementally to an existing C code-base allowing programmers to learn \CFA on an as-needed basis.
 
 \section{Overloading and extern}
 Cforall has overloading, allowing multiple definitions of the same name to
-be defined.
+be defined.~\cite{Moss18}
 
 This also adds name mangling so that the assembly symbols are unique for
@@ -11,19 +14,19 @@
 
 The syntax for disabling mangling is:
-\begin{lstlisting}
+\begin{cfa}
 extern "C" {
     ...
 }
-\end{lstlisting}
+\end{cfa}
 
 To re-enable mangling once it is disabled the syntax is:
-\begin{lstlisting}
+\begin{cfa}
 extern "Cforall" {
     ...
 }
-\end{lstlisting}
+\end{cfa}
 
 Both should occur at the declaration level and effect all the declarations
-in \texttt{...}. Neither care about the state of mangling when they begin
+in @...@. Neither care about the state of mangling when they begin
 and will return to that state after the group is finished. So re-enabling
 is only used to nest areas of mangled and unmangled declarations.
@@ -31,8 +34,8 @@
 \section{References}
 \CFA adds references to C. These are auto-dereferencing pointers and use the
-same syntax as pointers except they use ampersand (\codeCFA{\&}) instead of
-the asterisk (\codeCFA{*}). They can also be constaint or mutable, if they
+same syntax as pointers except they use ampersand (@&@) instead of
+the asterisk (@*@). They can also be constaint or mutable, if they
 are mutable they may be assigned to by using the address-of operator
-(\codeCFA\&) which converts them into a pointer.
+(@&@) which converts them into a pointer.
 
 \section{Constructors and Destructors}
@@ -41,22 +44,22 @@
 functions with special names. The special names are used to define them and
 may be used to call the functions expicately. The \CFA special names are
-constructed by taking the tokens in the operators and putting \texttt{?} where
-the arguments would go. So multiplication is \texttt{?*?} while dereference
-is \texttt{*?}. This also make it easy to tell the difference between
-pre-fix operations (such as \texttt{++?}) and post-fix operations
-(\texttt{?++}).
-
-The special name for contructors is \texttt{?\{\}}, which comes from the
+constructed by taking the tokens in the operators and putting @?@ where
+the arguments would go. So multiplication is @?*?@ while dereference
+is @*?@. This also make it easy to tell the difference between
+pre-fix operations (such as @++?@) and post-fix operations
+(@?++@).
+
+The special name for contructors is @?{}@, which comes from the
 initialization syntax in C. The special name for destructors is
-\texttt{\^{}?\{\}}. % I don't like the \^{} symbol but $^\wedge$ isn't better.
+@^{}@. % I don't like the \^{} symbol but $^\wedge$ isn't better.
 
 Any time a type T goes out of scope the destructor matching
-\codeCFA{void ^?\{\}(T \&);} is called. In theory this is also true of
-primitive types such as \codeCFA{int}, but in practice those are no-ops and
+@void ^?{}(T &);@ is called. In theory this is also true of
+primitive types such as @int@, but in practice those are no-ops and
 are usually omitted for optimization.
 
 \section{Polymorphism}
 \CFA uses polymorphism to create functions and types that are defined over
-different types. \CFA polymorphic declarations serve the same role as \CPP
+different types. \CFA polymorphic declarations serve the same role as \CC
 templates or Java generics.
 
@@ -65,9 +68,9 @@
 except that you may use the names introduced by the forall clause in them.
 
-Forall clauses are written \codeCFA{forall( ... )} where \codeCFA{...} becomes
+Forall clauses are written @forall( ... )@ where @...@ becomes
 the list of polymorphic variables (local type names) and assertions, which
 repersent required operations on those types.
 
-\begin{lstlisting}
+\begin{cfa}
 forall(dtype T | { void do_once(T &); })
 void do_twice(T & value) {
@@ -75,5 +78,5 @@
     do_once(value);
 }
-\end{lstlisting}
+\end{cfa}
 
 A polymorphic function can be used in the same way normal functions are.
@@ -83,7 +86,7 @@
 the the call site.
 
-As an example, even if no function named \codeCFA{do_once} is not defined
-near the definition of \codeCFA{do_twice} the following code will work.
-\begin{lstlisting}
+As an example, even if no function named @do_once@ is not defined
+near the definition of @do_twice@ the following code will work.
+\begin{cfa}
 int quadruple(int x) {
     void do_once(int & y) {
@@ -93,10 +96,10 @@
     return x;
 }
-\end{lstlisting}
+\end{cfa}
 This is not the recommended way to implement a quadruple function but it
-does work. The complier will deduce that \codeCFA{do_twice}'s T is an
+does work. The complier will deduce that @do_twice@'s T is an
 integer from the argument. It will then look for a definition matching the
-assertion which is the \codeCFA{do_once} defined within the function. That
-function will be passed in as a function pointer to \codeCFA{do_twice} and
+assertion which is the @do_once@ defined within the function. That
+function will be passed in as a function pointer to @do_twice@ and
 called within it.
 
@@ -104,15 +107,15 @@
 traits which collect assertions into convenent packages that can then be used
 in assertion lists instead of all of their components.
-\begin{lstlisting}
+\begin{cfa}
 trait done_once(dtype T) {
     void do_once(T &);
 }
-\end{lstlisting}
+\end{cfa}
 
 After this the forall list in the previous example could instead be written
 with the trait instead of the assertion itself.
-\begin{lstlisting}
+\begin{cfa}
 forall(dtype T | done_once(T))
-\end{lstlisting}
+\end{cfa}
 
 Traits can have arbitrary number of assertions in them and are usually used to
@@ -124,5 +127,5 @@
 are now used in field declaractions instead of parameters and local variables.
 
-\begin{lstlisting}
+\begin{cfa}
 forall(dtype T)
 struct node {
@@ -130,7 +133,7 @@
     T * data;
 }
-\end{lstlisting}
-
-The \codeCFA{node(T)} is a use of a polymorphic structure. Polymorphic types
+\end{cfa}
+
+The @node(T)@ is a use of a polymorphic structure. Polymorphic types
 must be provided their polymorphic parameters.
 
@@ -140,8 +143,8 @@
 \section{Concurrency}
 
-\CFA has a number of concurrency features, \codeCFA{thread}s,
-\codeCFA{monitor}s and \codeCFA{mutex} parameters, \codeCFA{coroutine}s and
-\codeCFA{generator}s. The two features that interact with the exception system
-are \codeCFA{thread}s and \codeCFA{coroutine}s; they and their supporting
+\CFA has a number of concurrency features, @thread@s,
+@monitor@s and @mutex@ parameters, @coroutine@s and
+@generator@s. The two features that interact with the exception system
+are @thread@s and @coroutine@s; they and their supporting
 constructs will be described here.
 
@@ -154,16 +157,16 @@
 library.
 
-In \CFA coroutines are created using the \codeCFA{coroutine} keyword which
-works just like \codeCFA{struct} except that the created structure will be
-modified by the compiler to satify the \codeCFA{is_coroutine} trait.
+In \CFA coroutines are created using the @coroutine@ keyword which
+works just like @struct@ except that the created structure will be
+modified by the compiler to satify the @is_coroutine@ trait.
 
 These structures act as the interface between callers and the coroutine,
 the fields are used to pass information in and out. Here is a simple example
 where the single field is used to pass the next number in a sequence out.
-\begin{lstlisting}
+\begin{cfa}
 coroutine CountUp {
     unsigned int next;
 }
-\end{lstlisting}
+\end{cfa}
 
 The routine part of the coroutine is a main function for the coroutine. It
@@ -173,5 +176,5 @@
 function it continue from that same suspend statement instead of at the top
 of the function.
-\begin{lstlisting}
+\begin{cfa}
 void main(CountUp & this) {
     unsigned int next = 0;
@@ -182,5 +185,5 @@
     }
 }
-\end{lstlisting}
+\end{cfa}
 
 Control is passed to the coroutine with the resume function. This includes the
@@ -189,5 +192,5 @@
 return value is for easy access to communication variables. For example the
 next value from a count-up can be generated and collected in a single
-expression: \codeCFA{resume(count).next}.
+expression: @resume(count).next@.
 
 \subsection{Monitors and Mutex}
@@ -198,6 +201,6 @@
 parameters.
 
-Function parameters can have the \codeCFA{mutex} qualifiers on reference
-arguments, for example \codeCFA{void example(a_monitor & mutex arg);}. When the
+Function parameters can have the @mutex@ qualifiers on reference
+arguments, for example @void example(a_monitor & mutex arg);@. When the
 function is called it will acquire the lock on all of the mutex parameters.
 
@@ -214,5 +217,5 @@
 
 Threads are created like coroutines except the keyword is changed:
-\begin{lstlisting}
+\begin{cfa}
 thread StringWorker {
     const char * input;
@@ -225,5 +228,5 @@
     this.result = result;
 }
-\end{lstlisting}
+\end{cfa}
 The main function will start executing after the fork operation and continue
 executing until it is finished. If another thread joins with this one it will
@@ -233,5 +236,5 @@
 From the outside this is the creation and destruction of the thread object.
 Fork happens after the constructor is run and join happens before the
-destructor runs. Join also happens during the \codeCFA{join} function which
+destructor runs. Join also happens during the @join@ function which
 can be used to join a thread earlier. If it is used the destructor does not
 join as that has already been completed.
