Changeset b5563e1 for doc/papers/general
- Timestamp:
- Mar 27, 2018, 10:21:32 AM (8 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, 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/Paper.tex
ra9b1b0c rb5563e1 671 671 \begin{cfa} 672 672 int f( int, int ); 673 intg( [int, int] );674 inth( int, [int, int] );673 [int] g( [int, int] ); 674 [int] h( int, [int, int] ); 675 675 [int, int] x; 676 676 int y; … … 706 706 This example shows mass, multiple, and cascading assignment used in one expression: 707 707 \begin{cfa} 708 voidf( [int, int] );708 [void] f( [int, int] ); 709 709 f( [x, y] = z = 1.5 ); $\C{// assignments in parameter list}$ 710 710 \end{cfa} … … 814 814 Flattening and restructuring conversions are also applied to tuple types in polymorphic type assertions. 815 815 \begin{cfa} 816 intf( [int, double], double );816 [int] f( [int, double], double ); 817 817 forall( otype T, otype U | { T f( T, U, U ); } ) void g( T, U ); 818 818 g( 5, 10.21 ); … … 1152 1152 case 4: 1153 1153 ... `fallthrough common;` 1154 common: // below fallthrough at same level as case clauses1154 `common`: // below fallthrough at same level as case clauses 1155 1155 ... // common code for cases 3 and 4 1156 1156 // implicit break … … 1857 1857 \begin{cfa} 1858 1858 struct S { double x, y; }; 1859 int i, j;1859 int x, y; 1860 1860 void 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}$1861 f( 3, x + y, (S){ 1.0, 7.0 }, (int [3]){ 1, 2, 3 } ); $\C{// pass rvalue to lvalue \(\Rightarrow\) implicit temporary}$ 1862 1862 \end{cfa} 1863 1863 This 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. … … 1946 1946 1947 1947 One 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 oftenverbose, and it is useful to manage resources other than memory (\eg file handles) using the same mechanism as memory.1948 However, this manual approach is verbose, and it is useful to manage resources other than memory (\eg file handles) using the same mechanism as memory. 1949 1949 \CC addresses these issues using Resource Aquisition Is Initialization (RAII), implemented by means of \newterm{constructor} and \newterm{destructor} functions; 1950 1950 \CFA adopts constructors and destructors (and @finally@) to facilitate RAII. … … 1998 1998 { 1999 1999 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 ); 2001 2001 ^x{}; $\C{// deallocate x}$ 2002 2002 x{}; $\C{// reallocate x}$ … … 2099 2099 2100 2100 For 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.2101 The 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. 2102 2102 The backquote is a small character, making the unit (function name) predominate. 2103 2103 For examples, the multi-precision integer-type in Section~\ref{s:MultiPrecisionIntegers} has user literals: … … 2107 2107 y = "12345678901234567890123456789"|`mp| + "12345678901234567890123456789"|`mp|; 2108 2108 \end{cfa} 2109 Because \CFA uses a standard function, all types and literals are applicable, as well as overloading and conversions .2109 Because \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. 2110 2110 }% 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} 2117 int ?`h( int s ); 2118 int ?`h( double s ); 2119 int ?`m( char c ); 2120 int ?`m( const char * s ); 2121 int ?`t( int a, int b, int c ); 2122 \end{cfa} 2123 & 2124 \begin{cfa} 2125 0 `h; 2126 3.5`h; 2127 '1'`m; 2128 "123" "456"`m; 2129 [1,2,3]`t; 2130 \end{cfa} 2131 & 2132 \begin{cfa} 2133 int i = 7; 2134 i`h; 2135 (i + 3)`h; 2136 (i + 3.5)`h; 2137 2138 \end{cfa} 2139 & 2140 \begin{cfa} 2141 int (* ?`p)( int i ); 2142 ?`p = ?`h; 2143 3`p; 2144 i`p; 2145 (i + 3)`p; 2146 \end{cfa} 2147 \end{tabular} 2148 \lstMakeShortInline@% 2149 \end{cquote} 2111 2150 2112 2151 The 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.