Changeset ad4458f
- Timestamp:
- Feb 22, 2018, 9:31:12 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 0304215a
- Parents:
- c27fb59
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/Paper.tex
rc27fb59 rad4458f 117 117 _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, _At, __attribute, 118 118 __attribute__, auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__, 119 __const, __const__, disable, dtype, enable, __extension__, fallthrough, fallthru,119 __const, __const__, disable, dtype, enable, exception, __extension__, fallthrough, fallthru, 120 120 finally, forall, ftype, _Generic, _Imaginary, inline, __label__, lvalue, _Noreturn, one_t, 121 121 otype, restrict, _Static_assert, throw, throwResume, trait, try, ttype, typeof, __typeof, … … 260 260 \Celeven did add @_Generic@ expressions, which can be used in preprocessor macros to provide a form of ad-hoc polymorphism; however, this polymorphism is both functionally and ergonomically inferior to \CFA name overloading. 261 261 The macro wrapping the generic expression imposes some limitations; as an example, it could not implement the example above, because the variables @max@ would collide with the functions @max@. 262 Ergonomic limitations of @_Generic@ include the necessity to put a fixed list of supported types in a single place and manually dispatch to appropriate overloads, as well as possible namespace pollution from the functions dispatched to, which must all have distinct names. 262 Ergonomic limitations of @_Generic@ include the necessity to put a fixed list of supported types in a single place and manually dispatch to appropriate overloads, as well as possible namespace pollution from the functions dispatched to, which must all have distinct names. 263 263 Though name-overloading removes a major use-case for @_Generic@ expressions, \CFA does implement @_Generic@ for backwards-compatibility purposes. \TODO{actually implement that} 264 264 … … 1357 1357 \subsection{Exception Handling} 1358 1358 1359 \CFA provides two forms of exception handling: \newterm{resumption} (fix-up) and \newterm{recovery} (see Figure~\ref{f:CFAExceptionHandling}). 1359 The following framework for \CFA exception handling is in place, excluding a run-time type information and dynamic casts. 1360 \CFA provides two forms of exception handling: \newterm{fix-up} and \newterm{recovery} (see Figure~\ref{f:CFAExceptionHandling}). 1360 1361 Both mechanisms provide dynamic call to a handler using dynamic name-lookup, where fix-up has dynamic return and recovery has static return from the handler. 1361 \CFA restricts exception types to those defined by aggregate type @ _Exception@.1362 \CFA restricts exception types to those defined by aggregate type @exception@. 1362 1363 The form of the raise dictates the set of handlers examined during propagation: \newterm{resumption propagation} (@resume@) only examines resumption handlers (@catchResume@); \newterm{terminating propagation} (@throw@) only examines termination handlers (@catch@). 1363 1364 If @resume@ or @throw@ have no exception type, it is a reresume/rethrow, meaning the currently exception continues propagation. 1364 If there is no current exception, the reresume/rethrow results in a nerror.1365 If there is no current exception, the reresume/rethrow results in a runtime error. 1365 1366 1366 1367 \begin{figure} … … 1370 1371 \multicolumn{1}{c@{\hspace{\parindentlnth}}}{\textbf{Resumption}} & \multicolumn{1}{c}{\textbf{Recovery}} \\ 1371 1372 \begin{cfa} 1372 ` _Exception R { int fix; };`1373 `exception R { int fix; };` 1373 1374 void f() { 1374 1375 R r; 1375 1376 ... `resume( r );` ... 1376 1377 ... r.fix // control does return here after handler 1378 } 1377 1379 `try` { 1378 1380 ... f(); ... … … 1383 1385 & 1384 1386 \begin{cfa} 1385 ` _Exception T {};`1387 `exception T {};` 1386 1388 void f() { 1387 1389 1388 1390 ... `throw( T{} );` ... 1389 1391 // control does NOT return here after handler 1392 } 1390 1393 `try` { 1391 1394 ... f(); ... … … 1420 1423 ... write( `datafile`, ... ); ... $\C{// may throw IOError}$ 1421 1424 ... write( `logfile`, ... ); ... 1422 } catch ( IOError err; `err == datafile` ) { ... } $\C{// handle datafile error}$1423 catch ( IOError err; `err == logfile` ) { ... } $\C{// handle logfile error}$1425 } catch ( IOError err; `err.file == datafile` ) { ... } $\C{// handle datafile error}$ 1426 catch ( IOError err; `err.file == logfile` ) { ... } $\C{// handle logfile error}$ 1424 1427 catch ( IOError err ) { ... } $\C{// handler error from other files}$ 1425 1428 \end{cfa} … … 1429 1432 The resumption raise can specify an alternate stack on which to raise an exception, called a \newterm{nonlocal raise}: 1430 1433 \begin{cfa} 1431 resume [ $\emph{exception-type}$ ] [ _At $\emph{alternate-stack}$ ] ; 1432 \end{cfa} 1433 The @_At@ clause raises the specified exception or the currently propagating exception (reresume) at another coroutine or task~\cite{Delisle18}. 1434 resume( $\emph{exception-type}$, $\emph{alternate-stack}$ ) 1435 resume( $\emph{alternate-stack}$ ) 1436 \end{cfa} 1437 These overloads of @resume@ raise the specified exception or the currently propagating exception (reresume) at another coroutine or task~\cite{Delisle18}. 1434 1438 Nonlocal raise is restricted to resumption to provide the exception handler the greatest flexibility because processing the exception does not unwind its stack, allowing it to continue after the handle returns. 1435 1439 … … 1622 1626 \lstMakeShortInline@% 1623 1627 \end{cquote} 1624 Specifiers must appear at the start of a \CFA routine declaration\footnote{\label{StorageClassSpecifier} .1628 Specifiers must appear at the start of a \CFA routine declaration\footnote{\label{StorageClassSpecifier} 1625 1629 The placement of a storage-class specifier other than at the beginning of the declaration specifiers in a declaration is an obsolescent feature.~\cite[\S~6.11.5(1)]{C11}}. 1626 1630 … … 1677 1681 * [ * int, int ] ( int ) jp; $\C{// pointer to routine returning pointer to int and int, with int parameter}$ 1678 1682 \end{cfa} 1679 Note, \emph{a routine name cannot be specified}:1683 Note, a routine name cannot be specified: 1680 1684 \begin{cfa} 1681 1685 * [ int x ] f () fp; $\C{// routine name "f" is disallowed}$ … … 1994 1998 The addition of @one_t@ allows generic algorithms to handle the unit value uniformly for types where that is meaningful. 1995 1999 \TODO{Make this sentence true} In particular, polymorphic functions in the \CFA prelude define @++x@ and @x++@ in terms of @x += 1@, allowing users to idiomatically define all forms of increment for a type @T@ by defining the single function @T & ?+=(T &, one_t)@; analogous overloads for the decrement operators are present as well. 2000 1996 2001 1997 2002 \subsection{Integral Suffixes} … … 2614 2619 \section{Acknowledgments} 2615 2620 2616 The authors would like to recognize the design assistance of Glen Ditchfield, Richard Bilson, and Thierry Delisle on the features described in this paper, and thank Magnus Madsen and the three anonymous reviewers for valuable feedback.2621 The authors would like to recognize the design assistance of Glen Ditchfield, Richard Bilson, and Thierry Delisle on the features described in this paper, and thank Magnus Madsen for feedback in the writing. 2617 2622 %This work is supported in part by a corporate partnership with \grantsponsor{Huawei}{Huawei Ltd.}{http://www.huawei.com}, and Aaron Moss and Peter Buhr are funded by the \grantsponsor{Natural Sciences and Engineering Research Council} of Canada. 2618 2623 % the first author's \grantsponsor{NSERC-PGS}{NSERC PGS D}{http://www.nserc-crsng.gc.ca/Students-Etudiants/PG-CS/BellandPostgrad-BelletSuperieures_eng.asp} scholarship.
Note: See TracChangeset
for help on using the changeset viewer.