Changeset b5563e1 for doc/papers/general


Ignore:
Timestamp:
Mar 27, 2018, 10:21:32 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
3d2b7bc
Parents:
a9b1b0c (diff), af1ed1ad (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

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

    ra9b1b0c rb5563e1  
    671671\begin{cfa}
    672672int f( int, int );
    673 int g( [int, int] );
    674 int h( int, [int, int] );
     673[int] g( [int, int] );
     674[int] h( int, [int, int] );
    675675[int, int] x;
    676676int y;
     
    706706This example shows mass, multiple, and cascading assignment used in one expression:
    707707\begin{cfa}
    708 void f( [int, int] );
     708[void] f( [int, int] );
    709709f( [x, y] = z = 1.5 );                                          $\C{// assignments in parameter list}$
    710710\end{cfa}
     
    814814Flattening and restructuring conversions are also applied to tuple types in polymorphic type assertions.
    815815\begin{cfa}
    816 int f( [int, double], double );
     816[int] f( [int, double], double );
    817817forall( otype T, otype U | { T f( T, U, U ); } ) void g( T, U );
    818818g( 5, 10.21 );
     
    11521152  case 4:
    11531153        ... `fallthrough common;`
    1154   common: // below fallthrough at same level as case clauses
     1154  `common`: // below fallthrough at same level as case clauses
    11551155        ...      // common code for cases 3 and 4
    11561156        // implicit break
     
    18571857\begin{cfa}
    18581858struct S { double x, y; };
    1859 int i, j;
     1859int x, y;
    18601860void f( int & i, int & j, S & s, int v[] );
    1861 f( 3, i + j, (S){ 1.0, 7.0 }, (int [3]){ 1, 2, 3 } );   $\C{// pass rvalue to lvalue \(\Rightarrow\) implicit temporary}$
     1861f( 3, x + y, (S){ 1.0, 7.0 }, (int [3]){ 1, 2, 3 } ); $\C{// pass rvalue to lvalue \(\Rightarrow\) implicit temporary}$
    18621862\end{cfa}
    18631863This allows complex values to be succinctly and efficiently passed to functions, without the syntactic overhead of explicit definition of a temporary variable or the runtime cost of pass-by-value.
     
    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.
     
    19981998{
    19991999        VLA  x,            y = { 20, 0x01 },     z = y; $\C{// z points to y}$
    2000         //      ?{}( x );  ?{}( y, 20, 0x01 );  ?{}( z, y );
     2000        //    ?{}( x );   ?{}( y, 20, 0x01 );    ?{}( z, y );
    20012001        ^x{};                                                                   $\C{// deallocate x}$
    20022002        x{};                                                                    $\C{// reallocate x}$
     
    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.