Changeset 84832d87


Ignore:
Timestamp:
Mar 23, 2018, 9:26:40 AM (6 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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, with_gc
Children:
766309d
Parents:
aac7197
Message:

extended postfix functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/papers/general/Paper.tex

    raac7197 r84832d87  
    19461946
    19471947One of the strengths (and weaknesses) of C is memory-management control, allowing resource release to be precisely specified versus unknown release with garbage-collected memory-management.
    1948 However, this manual approach is often verbose, and it is useful to manage resources other than memory (\eg file handles) using the same mechanism as memory.
     1948However, this manual approach is verbose, and it is useful to manage resources other than memory (\eg file handles) using the same mechanism as memory.
    19491949\CC addresses these issues using Resource Aquisition Is Initialization (RAII), implemented by means of \newterm{constructor} and \newterm{destructor} functions;
    19501950\CFA adopts constructors and destructors (and @finally@) to facilitate RAII.
     
    20992099
    21002100For readability, it is useful to associate units to scale literals, \eg weight (stone, pound, kilogram) or time (seconds, minutes, hours).
    2101 The left of Figure~\ref{f:UserLiteral} shows the \CFA alternative call-syntax (literal argument before function name), using the backquote, to convert basic literals into user literals.
     2101The left of Figure~\ref{f:UserLiteral} shows the \CFA alternative call-syntax (postfix: literal argument before function name), using the backquote, to convert basic literals into user literals.
    21022102The backquote is a small character, making the unit (function name) predominate.
    21032103For examples, the multi-precision integer-type in Section~\ref{s:MultiPrecisionIntegers} has user literals:
     
    21072107y = "12345678901234567890123456789"|`mp| + "12345678901234567890123456789"|`mp|;
    21082108\end{cfa}
    2109 Because \CFA uses a standard function, all types and literals are applicable, as well as overloading and conversions.
     2109Because \CFA uses a standard function, all types and literals are applicable, as well as overloading and conversions, where @?`@ denotes a postfix-function name and @`@ denotes a postfix-function call.
    21102110}%
     2111\begin{cquote}
     2112\lstset{language=CFA,moredelim=**[is][\color{red}]{|}{|},deletedelim=**[is][]{`}{`}}
     2113\lstDeleteShortInline@%
     2114\begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{\hspace{2\parindentlnth}}l@{\hspace{2\parindentlnth}}l@{}}
     2115\multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{postfix function}}        & \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{constant}}      & \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{variable/expression}}   & \multicolumn{1}{c}{\textbf{postfix pointer}}  \\
     2116\begin{cfa}
     2117int ?`h( int s );
     2118int ?`h( double s );
     2119int ?`m( char c );
     2120int ?`m( const char * s );
     2121int ?`t( int a, int b, int c );
     2122\end{cfa}
     2123&
     2124\begin{cfa}
     21250 `h;
     21263.5`h;
     2127'1'`m;
     2128"123" "456"`m;
     2129[1,2,3]`t;
     2130\end{cfa}
     2131&
     2132\begin{cfa}
     2133int i = 7;
     2134i`h;
     2135(i + 3)`h;
     2136(i + 3.5)`h;
     2137
     2138\end{cfa}
     2139&
     2140\begin{cfa}
     2141int (* ?`p)( int i );
     2142?`p = ?`h;
     21433`p;
     2144i`p;
     2145(i + 3)`p;
     2146\end{cfa}
     2147\end{tabular}
     2148\lstMakeShortInline@%
     2149\end{cquote}
    21112150
    21122151The right of Figure~\ref{f:UserLiteral} shows the equivalent \CC version using the underscore for the call-syntax.
Note: See TracChangeset for help on using the changeset viewer.