Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/andrew_beach_MMath/features.tex

    ra6c45c6 r6a8208cb  
    2020\subparagraph{Raise}
    2121The raise is the starting point for exception handling. It marks the beginning
    22 of exception handling by raising an excepion, which passes it to
     22of exception handling by \newterm{raising} an excepion, which passes it to
    2323the EHM.
    2424
     
    101101between different sub-hierarchies.
    102102This design is used in \CFA even though it is not a object-orientated
    103 language; so different tools are used to create the hierarchy.
     103language using different tools to create the hierarchy.
    104104
    105105% Could I cite the rational for the Python IO exception rework?
     
    123123\section{Virtuals}
    124124Virtual types and casts are not part of \CFA's EHM nor are they required for
    125 any EHM.
    126 However the \CFA uses a hierarchy built with the virtual system as the basis
    127 for exceptions and exception matching.
    128 
    129 The virtual system would have ideally been part of \CFA before the work
    130 on exception handling began, but unfortunately it was not.
    131 Because of this only the features and framework needed for the EHM were
    132 designed and implemented. Other features were considered to ensure that
    133 the structure could accomidate other desirable features but they were not
    134 implemented.
    135 The rest of this section will only discuss the finalized portion of the
    136 virtual system.
     125any EHM. But \CFA uses a hierarchial system of exceptions and this feature
     126is leveraged to create that.
     127
     128% Maybe talk about why the virtual system is so minimal.
     129% Created for but not a part of the exception system.
    137130
    138131The virtual system supports multiple ``trees" of types. Each tree is
     
    182175While much of the virtual infrastructure is created, it is currently only used
    183176internally for exception handling. The only user-level feature is the virtual
    184 cast, which is the same as the \Cpp \codeCpp{dynamic_cast}.
     177cast, which is the same as the \Cpp \lstinline[language=C++]|dynamic_cast|.
    185178\label{p:VirtualCast}
    186179\begin{cfa}
     
    204197\begin{cfa}
    205198trait is_exception(exceptT &, virtualT &) {
    206         // Numerous imaginary assertions.
     199        virtualT const & get_exception_vtable(exceptT *);
    207200};
    208201\end{cfa}
    209202The trait is defined over two types, the exception type and the virtual table
    210 type. Each exception type should have but a single virtual table type.
    211 Now there are no actual assertions in this trait because the trait system
    212 actually can't express them (adding such assertions would be part of
    213 completing the virtual system). The imaginary assertions would probably come
    214 from a trait defined by the virtual system, and state that the exception type
    215 is a virtual type, is a decendent of @exception_t@ (the base exception type)
    216 and note its virtual table type.
     203type. This should be one-to-one: each exception type has only one virtual
     204table type and vice versa. The only assertion in the trait is
     205@get_exception_vtable@, which takes a pointer of the exception type and
     206returns a reference to the virtual table type instance.
     207
     208% TODO: This section, and all references to get_exception_vtable, are
     209% out-of-data. Perhaps wait until the update is finished before rewriting it.
     210The function @get_exception_vtable@ is actually a constant function.
     211Regardless of the value passed in (including the null pointer) it should
     212return a reference to the virtual table instance for that type.
     213The reason it is a function instead of a constant is that it make type
     214annotations easier to write as you can use the exception type instead of the
     215virtual table type; which usually has a mangled name.
     216% Also \CFA's trait system handles functions better than constants and doing
     217% it this way reduce the amount of boiler plate we need.
    217218
    218219% I did have a note about how it is the programmer's responsibility to make
     
    234235Both traits ensure a pair of types are an exception type and its virtual table
    235236and defines one of the two default handlers. The default handlers are used
    236 as fallbacks and are discussed in detail in \vref{s:ExceptionHandling}.
     237as fallbacks and are discussed in detail in \VRef{s:ExceptionHandling}.
    237238
    238239However, all three of these traits can be tricky to use directly.
     
    350351for particular exception type.
    351352The global default termination handler performs a cancellation
    352 (see \vref{s:Cancellation}) on the current stack with the copied exception.
     353\see{\VRef{s:Cancellation}} on the current stack with the copied exception.
    353354
    354355\subsection{Resumption}
     
    425426
    426427\subsubsection{Resumption Marking}
    427 \label{s:ResumptionMarking}
    428428A key difference between resumption and termination is that resumption does
    429429not unwind the stack. A side effect that is that when a handler is matched
     
    472472The symmetry between resumption termination is why this pattern was picked.
    473473Other patterns, such as marking just the handlers that caught, also work but
    474 lack the symmetry means there are more rules to remember.
     474lack the symmetry means there are less rules to remember.
    475475
    476476\section{Conditional Catch}
     
    557557\end{cfa}
    558558If there are further handlers after this handler only the first version will
    559 check them. If multiple handlers on a single try block that could handle the
    560 same exception the translations get more complex but they are equivilantly
     559check them. If multiple handlers on a single try block could handle the same
     560exception the translations get more complex but they are equivilantly
    561561powerful.
    562562
     
    633633and the current stack is
    634634unwound. After that it depends one which stack is being cancelled.
    635 
    636 \paragraph{Main Stack}
     635\begin{description}
     636\item[Main Stack:]
    637637The main stack is the one used by the program main at the start of execution,
    638638and is the only stack in a sequential program.
     
    645645to, so it would have be explicitly managed.
    646646
    647 \paragraph{Thread Stack}
     647\item[Thread Stack:]
    648648A thread stack is created for a \CFA @thread@ object or object that satisfies
    649649the @is_thread@ trait.
     
    671671Also you can always add an explicit join if that is the desired behaviour.
    672672
    673 \paragraph{Coroutine Stack}
     673\item[Coroutine Stack:]
    674674A coroutine stack is created for a @coroutine@ object or object that
    675675satisfies the @is_coroutine@ trait.
     
    685685(in terms of coroutine state) called resume on this coroutine, so the message
    686686is passed to the latter.
     687\end{description}
Note: See TracChangeset for help on using the changeset viewer.