Ignore:
File:
1 edited

Legend:

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

    r7eb6eb5 r1c1c180  
    77Virtual types and casts are not required for a basic exception-system but are
    88useful for advanced exception features. However, \CFA is not object-oriented so
    9 there is no obvious concept of virtuals.  Hence, to create advanced exception
     9there is no obvious concept of virtuals. Hence, to create advanced exception
    1010features for this work, I needed to designed and implemented a virtual-like
    1111system for \CFA.
     
    3030\end{center}
    3131The hierarchy provides the ability to handle an exception at different degrees
    32 of specificity (left to right).  Hence, it is possible to catch a more general
     32of specificity (left to right). Hence, it is possible to catch a more general
    3333exception-type in higher-level code where the implementation details are
    3434unknown, which reduces tight coupling to the lower-level implementation.
     
    7878
    7979Exceptions are defined by the trait system; there are a series of traits, and
    80 if a type satisfies them, then it can be used as an exception.  The following
     80if a type satisfies them, then it can be used as an exception. The following
    8181is the base trait all exceptions need to match.
    8282\begin{cfa}
     
    9292\PAB{I do not understand this paragraph.}
    9393One odd thing about @get_exception_vtable@ is that it should always be a
    94 constant function, returning the same value regardless of its argument.  A
     94constant function, returning the same value regardless of its argument. A
    9595pointer or reference to the virtual table instance could be used instead,
    9696however using a function has some ease of implementation advantages and allows
    9797for easier disambiguation because the virtual type name (or the address of an
    9898instance that is in scope) can be used instead of the mangled virtual table
    99 name.  Also note the use of the word ``promise'' in the trait
     99name. Also note the use of the word ``promise'' in the trait
    100100description. Currently, \CFA cannot check to see if either @exceptT@ or
    101101@virtualT@ match the layout requirements. This is considered part of
     
    126126
    127127Finally there are three convenience macros for referring to the these traits:
    128 @IS_EXCEPTION@, @IS_TERMINATION_EXCEPTION@ and @IS_RESUMPTION_EXCEPTION@.  Each
     128@IS_EXCEPTION@, @IS_TERMINATION_EXCEPTION@ and @IS_RESUMPTION_EXCEPTION@. Each
    129129takes the virtual type's name, and for polymorphic types only, the
    130130parenthesized list of polymorphic arguments. These macros do the name mangling
     
    212212expression has a type with a @void defaultResumptionHandler(T &)@ (default
    213213handler) defined, where the handler is found at the call site by the type
    214 system.  At runtime, a representation of the exception type and an instance of
     214system. At runtime, a representation of the exception type and an instance of
    215215the exception type is \emph{not} copied because the stack is maintained during
    216216the handler search.
     
    306306exception matches, @CONDITION@ is executed. The condition expression may
    307307reference all names in scope at the beginning of the try block and @NAME@
    308 introduced in the handler clause.  If the condition is true, then the handler
     308introduced in the handler clause. If the condition is true, then the handler
    309309matches. Otherwise, the exception search continues at the next appropriate kind
    310310of handler clause in the try block.
     
    359359the end of the block. This requirement ensures always continues as if the
    360360finally clause is not present, \ie finally is for cleanup not changing control
    361 flow.  Because of this requirement, local control flow out of the finally block
    362 is forbidden.  The compiler precludes any @break@, @continue@, @fallthru@ or
     361flow. Because of this requirement, local control flow out of the finally block
     362is forbidden. The compiler precludes any @break@, @continue@, @fallthru@ or
    363363@return@ that causes control to leave the finally block. Other ways to leave
    364364the finally block, such as a long jump or termination are much harder to check,
     
    371371
    372372There is no special statement for starting a cancellation; instead the standard
    373 library function @cancel_stack@ is called passing an exception.  Unlike a
     373library function @cancel_stack@ is called passing an exception. Unlike a
    374374raise, this exception is not used in matching only to pass information about
    375375the cause of the cancellation.
     
    379379\item[Main Stack:]
    380380The main stack is the one used by the program main at the start of execution,
    381 and is the only stack in a sequential program.  Hence, when cancellation is
     381and is the only stack in a sequential program. Hence, when cancellation is
    382382forwarded to the main stack, there is no other forwarding stack, so after the
    383383stack is unwound, there is a program-level abort.
     
    385385\item[Thread Stack:]
    386386A thread stack is created for a @thread@ object or object that satisfies the
    387 @is_thread@ trait.  A thread only has two points of communication that must
     387@is_thread@ trait. A thread only has two points of communication that must
    388388happen: start and join. As the thread must be running to perform a
    389389cancellation, it must occur after start and before join, so join is a
    390 cancellation point.  After the stack is unwound, the thread halts and waits for
     390cancellation point. After the stack is unwound, the thread halts and waits for
    391391another thread to join with it. The joining thread, checks for a cancellation,
    392392and if present, resumes exception @ThreadCancelled@.
     
    408408
    409409\item[Coroutine Stack:] A coroutine stack is created for a @coroutine@ object
    410 or object that satisfies the @is_coroutine@ trait.  A coroutine only knows of
    411 two other coroutines, its starter and its last resumer.  The last resumer has
    412 the tightest coupling to the coroutine it activated.  Hence, cancellation of
     410or object that satisfies the @is_coroutine@ trait. A coroutine only knows of
     411two other coroutines, its starter and its last resumer. The last resumer has
     412the tightest coupling to the coroutine it activated. Hence, cancellation of
    413413the active coroutine is forwarded to the last resumer after the stack is
    414414unwound, as the last resumer has the most precise knowledge about the current
Note: See TracChangeset for help on using the changeset viewer.