Changes in doc/papers/general/Paper.tex [ad4458f:4ada74e]
- File:
-
- 1 edited
-
doc/papers/general/Paper.tex (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/Paper.tex
rad4458f r4ada74e 41 41 42 42 \newcommand{\Textbf}[2][red]{{\color{#1}{\textbf{#2}}}} 43 %\newcommand{\TODO}[1]{\textbf{TODO}: {\itshape #1}} % TODO included44 \newcommand{\TODO}[1]{} % TODO elided43 \newcommand{\TODO}[1]{\textbf{TODO}: {\itshape #1}} % TODO included 44 %\newcommand{\TODO}[1]{} % TODO elided 45 45 46 46 % Default underscore is too low and wide. Cannot use lstlisting "literate" as replacing underscore … … 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, exception,__extension__, fallthrough, fallthru,119 __const, __const__, disable, dtype, enable, __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, … … 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 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 Though name-overloading removes a major use-case for @_Generic@ expressions, \CFA does implement @_Generic@ for backwards-compatibility purposes. \TODO{actually implement that}264 263 265 264 % http://fanf.livejournal.com/144696.html … … 1357 1356 \subsection{Exception Handling} 1358 1357 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}). 1358 \CFA provides two forms of exception handling: \newterm{resumption} (fix-up) and \newterm{recovery} (see Figure~\ref{f:CFAExceptionHandling}). 1361 1359 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. 1362 \CFA restricts exception types to those defined by aggregate type @ exception@.1360 \CFA restricts exception types to those defined by aggregate type @_Exception@. 1363 1361 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@). 1364 1362 If @resume@ or @throw@ have no exception type, it is a reresume/rethrow, meaning the currently exception continues propagation. 1365 If there is no current exception, the reresume/rethrow results in a runtimeerror.1363 If there is no current exception, the reresume/rethrow results in an error. 1366 1364 1367 1365 \begin{figure} … … 1371 1369 \multicolumn{1}{c@{\hspace{\parindentlnth}}}{\textbf{Resumption}} & \multicolumn{1}{c}{\textbf{Recovery}} \\ 1372 1370 \begin{cfa} 1373 ` exception R { int fix; };`1371 `_Exception R { int fix; };` 1374 1372 void f() { 1375 1373 R r; 1376 1374 ... `resume( r );` ... 1377 1375 ... r.fix // control does return here after handler 1378 }1379 1376 `try` { 1380 1377 ... f(); ... … … 1385 1382 & 1386 1383 \begin{cfa} 1387 ` exception T {};`1384 `_Exception T {};` 1388 1385 void f() { 1389 1386 1390 1387 ... `throw( T{} );` ... 1391 1388 // control does NOT return here after handler 1392 }1393 1389 `try` { 1394 1390 ... f(); ... … … 1423 1419 ... write( `datafile`, ... ); ... $\C{// may throw IOError}$ 1424 1420 ... write( `logfile`, ... ); ... 1425 } catch ( IOError err; `err .file== datafile` ) { ... } $\C{// handle datafile error}$1426 catch ( IOError err; `err .file== logfile` ) { ... } $\C{// handle logfile error}$1421 } catch ( IOError err; `err == datafile` ) { ... } $\C{// handle datafile error}$ 1422 catch ( IOError err; `err == logfile` ) { ... } $\C{// handle logfile error}$ 1427 1423 catch ( IOError err ) { ... } $\C{// handler error from other files}$ 1428 1424 \end{cfa} … … 1432 1428 The resumption raise can specify an alternate stack on which to raise an exception, called a \newterm{nonlocal raise}: 1433 1429 \begin{cfa} 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}. 1430 resume [ $\emph{exception-type}$ ] [ _At $\emph{alternate-stack}$ ] ; 1431 \end{cfa} 1432 The @_At@ clause raises the specified exception or the currently propagating exception (reresume) at another coroutine or task~\cite{Delisle18}. 1438 1433 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. 1439 1434 … … 1626 1621 \lstMakeShortInline@% 1627 1622 \end{cquote} 1628 Specifiers must appear at the start of a \CFA routine declaration\footnote{\label{StorageClassSpecifier} 1623 Specifiers must appear at the start of a \CFA routine declaration\footnote{\label{StorageClassSpecifier}. 1629 1624 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}}. 1630 1625 … … 1681 1676 * [ * int, int ] ( int ) jp; $\C{// pointer to routine returning pointer to int and int, with int parameter}$ 1682 1677 \end{cfa} 1683 Note, a routine name cannot be specified:1678 Note, \emph{a routine name cannot be specified}: 1684 1679 \begin{cfa} 1685 1680 * [ int x ] f () fp; $\C{// routine name "f" is disallowed}$ … … 1989 1984 1990 1985 In C, @0@ has the special property that it is the only ``false'' value; by the standard, any value which compares equal to @0@ is false, while any value that compares unequal to @0@ is true. 1991 As such, an expression @x@ in any boolean context (such as the condition of an @if@ or @while@ statement, or the arguments to @&&@, @||@, or @?:@) can be rewritten as @x != 0@ without changing its semantics.1986 As such, an expression @x@ in any boolean context (such as the condition of an @if@ or @while@ statement, or the arguments to an @&&@, @||@, or ternary operator) can be rewritten as @x != 0@ without changing its semantics. 1992 1987 The operator overloading feature of \CFA provides a natural means to implement this truth value comparison for arbitrary types, but the C type system is not precise enough to distinguish an equality comparison with @0@ from an equality comparison with an arbitrary integer or pointer. 1993 To provide this precision, \CFA introduces a new type @zero_t@ as type type of literal @0@ (somewhat analagous to @nullptr_t@ and @nullptr@ in \CCeleven); @zero_t@ can only take the value @0@, but has implicit conversions to the integer and pointer types so that C code involving @0@ continues to work properly.1988 To provide this precision, \CFA introduces a new type @zero_t@ as type type of literal @0@ (somewhat analagous to @nullptr_t@ and @nullptr@ in \CCeleven); @zero_t@ can only take the value @0@, but has implicit conversions to the integer and pointer types so that standard C code involving @0@ continues to work properly. 1994 1989 With this addition, the \CFA compiler rewrites @if (x)@ and similar expressions to @if ((x) != 0)@ or the appropriate analogue, and any type @T@ can be made ``truthy'' by defining an operator overload @int ?!=?(T, zero_t)@. 1995 1990 \CC makes types truthy by adding a conversion to @bool@; prior to the addition of explicit cast operators in \CCeleven this approach had the pitfall of making truthy types transitively convertable to any numeric type; our design for \CFA avoids this issue. … … 2619 2614 \section{Acknowledgments} 2620 2615 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.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. 2622 2617 %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. 2623 2618 % 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.