 Timestamp:
 Apr 30, 2016, 2:05:06 PM (8 years ago)
 Branches:
 ADT, aaronthesis, armeh, astexperimental, cleanupdtors, ctor, deferred_resn, demangler, enum, forallpointerdecay, gc_noraii, jacob/cs343translation, jenkinssandbox, master, memory, newast, newastuniqueexpr, newenv, no_list, persistentindexer, pthreademulation, qualifiedEnum, resolvnew, with_gc
 Children:
 0638c44, 1048b31, fbfde843
 Parents:
 8bc4ef8
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

doc/user/user.tex
r8bc4ef8 re945826 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Thu Apr 28 14:45:07201614 %% Update Count : 18113 %% Last Modified On : Sat Apr 30 13:54:32 2016 14 %% Update Count : 221 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 17 17 % requires tex packages: texlivebase texlivelatexbase texcommon texlivehumanities texlivelatexextra texlivefontsrecommended 18 19 % red highlighting ®...® (registered trademark sumbol) 20 % blue highlighting ©...© (copyright symbol) 21 % latex escape §...§ (section symbol) 22 % keyword escape ¶...¶ (pilcrow symbol) 23 % math escape $...$ (dollar symbol) 18 24 19 25 \documentclass[openright,twoside]{article} … … 231 237 This command works like the GNU \lstinline@gcc@\index{gcc} command, e.g.: 232 238 \begin{lstlisting} 233 cfa [ gccoptions ] C/ @{\CFA}@files [ assembler/loaderfiles ]239 cfa [ gccoptions ] C/§\CFA§files [ assembler/loaderfiles ] 234 240 \end{lstlisting} 235 241 \indexc{cfa}\index{compilation!cfa@\lstinline$cfa$} 236 242 By default, \CFA programs having the following \lstinline@gcc@ flags turned on: 237 243 \begin{description} 238 \item 239 \hspace*{4pt}\lstinline@std=gnu99@ 240 \indexc{std=gnu99}\index{compilation option!std=gnu99@{\lstinline$std=gnu99$}} 244 \item\hspace*{4pt}\Indexc{std=gnu99}\index{compilation option!std=gnu99@{\lstinline$std=gnu99$}} 241 245 The 1999 C standard plus GNU extensions. 242 \item 243 \hspace*{4pt}\lstinline@fgnu89inline@ 244 \indexc{fgnu89inline}\index{compilation option!fgnu89inline@{\lstinline$fgnu89inline$}} 246 \item\hspace*{4pt}\Indexc{fgnu89¶inline¶}\index{compilation option!fgnu89inline@{\lstinline$fgnu89¶inline¶$}} 245 247 Use the traditional GNU semantics for inline routines in C99 mode. 246 248 \end{description} 247 249 The following new \CFA option is available: 248 250 \begin{description} 249 \item 250 \hspace*{4pt}\lstinline@CFA@ 251 \indexc{CFA}\index{compilation option!CFA@{\lstinline$CFA$}} 251 \item\hspace*{4pt}\Indexc{CFA}\index{compilation option!CFA@{\lstinline$CFA$}} 252 252 Only the C preprocessor and the \CFA translator steps are performed and the transformed program is written to standard output, which makes it possible to examine the code generated by the \CFA translator. 253 253 \end{description} … … 255 255 The following preprocessor variables are available: 256 256 \begin{description} 257 \item 258 \hspace*{4pt}\lstinline$__CFA__$ 259 \indexc{__CFA__}\index{preprocessor variables!__CFA__@{\lstinline$__CFA__$}} 257 \item\hspace*{4pt}\Indexc{__CFA__}\index{preprocessor variables!__CFA__@{\lstinline$__CFA__$}} 260 258 is always available during preprocessing and its value is the current major \Index{version number} of \CFA.\footnote{ 261 259 The C preprocessor allows only integer values in a preprocessor variable so a value like ``\Version'' is not allowed. 262 260 Hence, the need to have three variables for the major, minor and patch version number.} 263 261 264 \item 265 \hspace*{4pt}\lstinline$__CFA_MINOR__$ 266 \indexc{__CFA_MINOR__}\index{preprocessor variables!__CFA_MINOR__@{\lstinline$__CFA_MINOR__$}} 262 \item\hspace*{4pt}\Indexc{__CFA_MINOR__}\index{preprocessor variables!__CFA_MINOR__@{\lstinline$__CFA_MINOR__$}} 267 263 is always available during preprocessing and its value is the current minor \Index{version number} of \CFA. 268 264 269 \item 270 \hspace*{4pt}\lstinline$__CFA_PATCH__$ 271 \indexc{__CFA_PATCH__}\index{preprocessor variables!__CFA_PATCH__@\lstinline$__CFA_PATCH__$} 265 \item\hspace*{4pt}\Indexc{__CFA_PATCH__}\index{preprocessor variables!__CFA_PATCH__@\lstinline$__CFA_PATCH__$} 272 266 is always available during preprocessing and its value is the current patch \Index{version number} of \CFA. 273 267 274 \item 275 \hspace*{4pt}\lstinline$__CFORALL__$ 276 \indexc{__CFORALL__}\index{preprocessor variables!__CFORALL__@\lstinline$__CFORALL__$} 268 \item\hspace*{4pt}\Indexc{__CFORALL__}\index{preprocessor variables!__CFORALL__@\lstinline$__CFORALL__$} 277 269 is always available during preprocessing and it has no value. 278 270 \end{description} … … 282 274 \begin{lstlisting} 283 275 #ifndef __CFORALL__ 284 #include <stdio.h> // C header file276 #include <stdio.h> // C header file 285 277 #else 286 #include <fstream> // @\CFA{}@header file278 #include <fstream> // §\CFA{}§ header file 287 279 #endif 288 280 \end{lstlisting} … … 294 286 Numeric constants are extended to allow \Index{underscore}s within constants\index{constant!underscore}, e.g.: 295 287 \begin{lstlisting} 296 2 `_`147`_`483`_`648; // decimal constant288 2®_®147®_®483®_®648; // decimal constant 297 289 56_ul; // decimal unsigned long constant 298 290 0_377; // octal constant … … 360 352 \multicolumn{1}{c@{\hspace{30pt}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 361 353 \begin{lstlisting} 362 `* int x, y;` 354 ®* int x, y;® 363 355 \end{lstlisting} 364 356 & … … 488 480 The point of the new syntax is to allow returning multiple values from a routine~\cite{CLU,Galletly96}, e.g.: 489 481 \begin{lstlisting} 490 `[ int o1, int o2, char o3 ]`f( int i1, char i2, char i3 ) {491 @\emph{routine body}@482 ®[ int o1, int o2, char o3 ]® f( int i1, char i2, char i3 ) { 483 §\emph{routine body}§ 492 484 } 493 485 \end{lstlisting} … … 500 492 Declaration qualifiers can only appear at the start of a routine definition, e.g.: 501 493 \begin{lstlisting} 502 extern [ int x ] g( int y ) { @\,@}494 extern [ int x ] g( int y ) {§\,§} 503 495 \end{lstlisting} 504 496 Lastly, if there are no output parameters or input parameters, the brackets and/or parentheses must still be specified; 505 497 in both cases the type is assumed to be void as opposed to old style C defaults of int return type and unknown parameter types, respectively, as in: 506 498 \begin{lstlisting} 507 [ @\,@] g(); // no input or output parameters499 [§\,§] g(); // no input or output parameters 508 500 [ void ] g( void ); // no input or output parameters 509 501 \end{lstlisting} … … 556 548 Because the value in the return variable is automatically returned when a \CFA routine terminates, the \lstinline@return@ statement \emph{does not} contain an expression, as in: 557 549 \begin{lstlisting} 558 `[ int x ]`f() {550 ®[ int x ]® f() { 559 551 ... x = 0; ... x = y; ... 560 `return;`// implicitly return x552 ®return;® // implicitly return x 561 553 } 562 554 \end{lstlisting} … … 836 828 837 829 int fred() { 838 s.t.c = `S.`R; // type qualification839 struct `S.`T t = { `S.`R, 1, 2 };840 enum `S.`C c;841 union `S.T.`U u;830 s.t.c = ®S.®R; // type qualification 831 struct ®S.®T t = { ®S.®R, 1, 2 }; 832 enum ®S.®C c; 833 union ®S.T.®U u; 842 834 } 843 835 \end{lstlisting} … … 863 855 qsort( ia, size ); // sort ascending order using builtin ?<? 864 856 { 865 `int ?<?( int x, int y ) { return x > y; }`// nested routine857 ®int ?<?( int x, int y ) { return x > y; }® // nested routine 866 858 qsort( ia, size ); // sort descending order by local redefinition 867 859 } … … 873 865 \begin{lstlisting} 874 866 [* [int]( int )] foo() { // int (*foo())( int ) 875 int `i`= 7;867 int ®i® = 7; 876 868 int bar( int p ) { 877 `i`+= 1; // dependent on local variable878 sout  `i` endl;869 ®i® += 1; // dependent on local variable 870 sout  ®i®  endl; 879 871 } 880 872 return bar; // undefined because of local dependence … … 897 889 The general syntax of a tuple is: 898 890 \begin{lstlisting} 899 [ $\emph{exprlist}$]891 [ §\emph{exprlist}§ ] 900 892 \end{lstlisting} 901 893 where \lstinline@$\emph{exprlist}$@ is a list of one or more expressions separated by commas. … … 917 909 The general syntax of a tuple type is: 918 910 \begin{lstlisting} 919 [ @\emph{typelist}@]911 [ §\emph{typelist}§ ] 920 912 \end{lstlisting} 921 913 where \lstinline@$\emph{typelist}$@ is a list of one or more legal \CFA or C type specifications separated by commas, which may include other tuple type specifications. … … 1047 1039 Mass assignment has the following form: 1048 1040 \begin{lstlisting} 1049 [ @\emph{lvalue}@, ..., @\emph{lvalue}@ ] = @\emph{expr}@;1050 \end{lstlisting} 1051 The lefthand side is a tuple of \ lstinline@$\emph{lvalues}$@, which is a list of expressions each yielding an address, i.e., any data object that can appear on the lefthand side of a conventional assignment statement.1041 [ §\emph{lvalue}§, ..., §\emph{lvalue}§ ] = §\emph{expr}§; 1042 \end{lstlisting} 1043 The lefthand side is a tuple of \emph{lvalues}, which is a list of expressions each yielding an address, i.e., any data object that can appear on the lefthand side of a conventional assignment statement. 1052 1044 \lstinline@$\emph{expr}$@ is any standard arithmetic expression. 1053 1045 Clearly, the types of the entities being assigned must be type compatible with the value of the expression. … … 1086 1078 Multiple assignment has the following form: 1087 1079 \begin{lstlisting} 1088 [ @\emph{lvalue}@, . . ., @\emph{lvalue}@ ] = [ @\emph{expr}@, . . ., @\emph{expr}@];1089 \end{lstlisting} 1090 The lefthand side is a tuple of \ lstinline@$\emph{lvalues}$@, and the righthand side is a tuple of \lstinline@$\emph{expr}$@s.1091 Each \ lstinline@$\emph{expr}$@ appearing on the righthand side of a multiple assignment statement is assigned to the corresponding \lstinline@$\emph{lvalues}$@on the lefthand side of the statement using parallel semantics for each assignment.1080 [ §\emph{lvalue}§, . . ., §\emph{lvalue}§ ] = [ §\emph{expr}§, . . ., §\emph{expr}§ ]; 1081 \end{lstlisting} 1082 The lefthand side is a tuple of \emph{lvalues}, and the righthand side is a tuple of \emph{expr}s. 1083 Each \emph{expr} appearing on the righthand side of a multiple assignment statement is assigned to the corresponding \emph{lvalues} on the lefthand side of the statement using parallel semantics for each assignment. 1092 1084 An example of multiple assignment is: 1093 1085 \begin{lstlisting} … … 1126 1118 Cascade assignment has the following form: 1127 1119 \begin{lstlisting} 1128 @\emph{tuple}@ = @\emph{tuple}@ = ... = @\emph{tuple}@;1120 §\emph{tuple}§ = §\emph{tuple}§ = ... = §\emph{tuple}§; 1129 1121 \end{lstlisting} 1130 1122 and it has the same parallel semantics as for mass and multiple assignment. … … 1144 1136 Its general form is: 1145 1137 \begin{lstlisting} 1146 @\emph{expr}@ . [ @\emph{fieldlist}@]1147 @\emph{expr}@ > [ @\emph{fieldlist}@]1148 \end{lstlisting} 1149 \ lstinline@$\emph{expr}$@is any expression yielding a value of type record, e.g., \lstinline@struct@, \lstinline@union@.1150 Each element of \ lstinline@$\emph{ fieldlist}$@ is an element of the record specified by \lstinline@$\emph{expr}$@.1138 §\emph{expr}§ . [ §\emph{fieldlist}§ ] 1139 §\emph{expr}§ > [ §\emph{fieldlist}§ ] 1140 \end{lstlisting} 1141 \emph{expr} is any expression yielding a value of type record, e.g., \lstinline@struct@, \lstinline@union@. 1142 Each element of \emph{ fieldlist} is an element of the record specified by \emph{expr}. 1151 1143 A recordfield tuple may be used anywhere a tuple can be used. An example of the use of a recordfield tuple is 1152 1144 the following: … … 1188 1180 \multicolumn{1}{c@{\hspace{30pt}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1189 1181 \begin{lstlisting} 1190 `L1:`for ( ... ) {1191 `L2:`for ( ... ) {1192 `L3:`for ( ... ) {1193 ... break `L1`; ...1194 ... break `L2`; ...1195 ... break `L3`; // or break1182 ®L1:® for ( ... ) { 1183 ®L2:® for ( ... ) { 1184 ®L3:® for ( ... ) { 1185 ... break ®L1®; ... 1186 ... break ®L2®; ... 1187 ... break ®L3®; // or break 1196 1188 } 1197 1189 } … … 1218 1210 \multicolumn{1}{c@{\hspace{30pt}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1219 1211 \begin{lstlisting} 1220 `L1`: for ( ... ) {1221 `L2`: for ( ... ) {1222 `L3`: for ( ... ) {1223 ... continue `L1`; ...1224 ... continue `L2`; ...1225 ... continue `L3`; ...1212 ®L1®: for ( ... ) { 1213 ®L2®: for ( ... ) { 1214 ®L3®: for ( ... ) { 1215 ... continue ®L1®; ... 1216 ... continue ®L2®; ... 1217 ... continue ®L3®; ... 1226 1218 1227 1219 } … … 1459 1451 \begin{lstlisting} 1460 1452 switch ( i ) { 1461 `case 1, 3, 5`:1453 ®case 1, 3, 5®: 1462 1454 ... 1463 `case 2, 4, 6`:1455 ®case 2, 4, 6®: 1464 1456 ... 1465 1457 } … … 1491 1483 \begin{lstlisting} 1492 1484 switch ( i ) { 1493 `case 1~5:`1485 ®case 1~5:® 1494 1486 ... 1495 `case 10~15:`1487 ®case 10~15:® 1496 1488 ... 1497 1489 } … … 2048 2040 For example, given 2049 2041 \begin{lstlisting} 2050 auto j = `...`2042 auto j = ®...® 2051 2043 \end{lstlisting} 2052 2044 and the need to write a routine to compute using \lstinline@j@ 2053 2045 \begin{lstlisting} 2054 void rtn( `...`parm );2046 void rtn( ®...® parm ); 2055 2047 rtn( j ); 2056 2048 \end{lstlisting} … … 2372 2364 To make this work, a space is required after the field selection: 2373 2365 \begin{lstlisting} 2374 `s.@\textvisiblespace@0`= 0;2375 `s.@\textvisiblespace@1`= 1;2366 ®s.§\textvisiblespace§0® = 0; 2367 ®s.§\textvisiblespace§1® = 1; 2376 2368 \end{lstlisting} 2377 2369 While this sytact is awkward, it is unlikely many programers will name fields of a structure 0 or 1. 2378 Like the \CC lexical problem with closing templatesyntax, e.g, \lstinline@Foo<Bar<int `>>`@, this issue can be solved with a more powerful lexer/parser.2370 Like the \CC lexical problem with closing templatesyntax, e.g, \lstinline@Foo<Bar<int®>>®@, this issue can be solved with a more powerful lexer/parser. 2379 2371 2380 2372 There are several ambiguous cases with operator identifiers, e.g., \lstinline@int *?*?()@, where the string \lstinline@*?*?@ can be lexed as \lstinline@*@/\lstinline@?*?@ or \lstinline@*?@/\lstinline@*?@. … … 2383 2375 The first case is for the functioncall identifier \lstinline@?()@: 2384 2376 \begin{lstlisting} 2385 int * @\textvisiblespace@?()(); // declaration: space required after '*'2386 * @\textvisiblespace@?()(); // expression: space required after '*'2377 int *§\textvisiblespace§?()(); // declaration: space required after '*' 2378 *§\textvisiblespace§?()(); // expression: space required after '*' 2387 2379 \end{lstlisting} 2388 2380 Without the space, the string \lstinline@*?()@ is ambiguous without N character look ahead; … … 2391 2383 The 4 remaining cases occur in expressions: 2392 2384 \begin{lstlisting} 2393 i++ @\textvisiblespace@?i:0; // space required before '?'2394 i @\textvisiblespace@?i:0; // space required before '?'2395 i @\textvisiblespace@?++i:0; // space required after '?'2396 i @\textvisiblespace@?i:0; // space required after '?'2385 i++§\textvisiblespace§?i:0; // space required before '?' 2386 i§\textvisiblespace§?i:0; // space required before '?' 2387 i§\textvisiblespace§?++i:0; // space required after '?' 2388 i§\textvisiblespace§?i:0; // space required after '?' 2397 2389 \end{lstlisting} 2398 2390 In the first two cases, the string \lstinline@i++?@ is ambiguous, where this string can be lexed as \lstinline@i@ / \lstinline@++?@ or \lstinline@i++@ / \lstinline@?@; … … 4079 4071 Given that nested types in C are equivalent to not using them, i.e., they are essentially useless, it is unlikely there are any realistic usages that break because of this incompatibility. 4080 4072 4081 4082 4073 \item 4083 4074 Change: In C++, the name of a nested class is local to its enclosing class. … … 4090 4081 struct Y yy; // valid C, invalid C++ 4091 4082 \end{lstlisting} 4092 Rationale: C++ classes have member functions which require that classes establish scopes. The C rule 4093 would leave classes as an incomplete scope mechanism which would prevent C++ programmers from maintaining 4094 locality within a class. A coherent set of scope rules for C++ based on the C rule would be very 4095 complicated and C++ programmers would be unable to predict reliably the meanings of nontrivial examples 4096 involving nested or local functions. 4097 Effect on original feature: Change of semantics of welldefined 4098 feature. 4099 Difficulty of converting: Semantic transformation. To make the struct type name visible in the scope of 4100 the enclosing struct, the struct tag could be declared in the scope of the enclosing struct, before the enclosing 4101 struct is defined. Example: 4083 Rationale: C++ classes have member functions which require that classes establish scopes. 4084 The C rule would leave classes as an incomplete scope mechanism which would prevent C++ programmers from maintaining locality within a class. A coherent set of scope rules for C++ based on the C rule would be very complicated and C++ programmers would be unable to predict reliably the meanings of nontrivial examples involving nested or local functions. 4085 Effect on original feature: Change of semantics of welldefined feature. 4086 Difficulty of converting: Semantic transformation. To make the struct type name visible in the scope of the enclosing struct, the struct tag could be declared in the scope of the enclosing struct, before the enclosing struct is defined. Example: 4102 4087 \begin{lstlisting} 4103 4088 struct Y; // struct Y and struct X are at the same scope … … 4106 4091 }; 4107 4092 \end{lstlisting} 4108 All the definitions of C struct types enclosed in other struct definitions and accessed outside the scope of 4109 the enclosing struct could be exported to the scope of the enclosing struct. Note: this is a consequence of 4110 the difference in scope rules, which is documented in 3.3. 4093 All the definitions of C struct types enclosed in other struct definitions and accessed outside the scope of the enclosing struct could be exported to the scope of the enclosing struct. 4094 Note: this is a consequence of the difference in scope rules, which is documented in 3.3. 4111 4095 How widely used: Seldom. 4112 4096 \end{enumerate} … … 4124 4108 \begin{lstlisting} 4125 4109 int x = 0, y = 1, z = 2; 4126 `sout` `` x `` y `` z ` endl`;4110 ®sout® ®® x ®® y ®® z ® endl®; 4127 4111 \end{lstlisting} 4128 4112 & … … 4133 4117 \end{tabular} 4134 4118 \end{quote2} 4135 The \CFA form is half as many characters, and is similar to PythonI/O with respect to implicit separators.4119 The \CFA form is half as many characters, and is similar to \Index{Python} I/O with respect to implicit separators. 4136 4120 4137 4121 The logicalor operator is used because it is the lowestpriority overloadable operator, other than assignment. … … 4179 4163 which is a local mechanism to disable insertion of the separator character. 4180 4164 \item 4181 A seperator does not appear before a C string starting with the (extended) \Index{ASCII}\index{ASCII!extended} characters: \lstinline[mathescape=off]@([{$£¥ ¿«@4165 A seperator does not appear before a C string starting with the (extended) \Index{ASCII}\index{ASCII!extended} characters: \lstinline[mathescape=off]@([{$£¥¡¿«@ 4182 4166 %$ 4183 4167 \begin{lstlisting}[mathescape=off] 4184 sout  "x ("  1  "x ["  2  "x {"  3  "x $"  4  "x £"  5  "x ¥"  6  "x ¿"  7  "x «"  8 endl;4168 sout  "x ("  1  "x ["  2  "x {"  3  "x $"  4  "x £"  5  "x ¥"  6  "x ¡"  7  "x ¿"  8  "x «"  9  endl; 4185 4169 \end{lstlisting} 4186 4170 %$ 4187 4171 \begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] 4188 x (1 x [2 x {3 x $4 x £5 x ¥6 x ¿7 x «84172 x (1 x [2 x {3 x $4 x £5 x ¥6 x ¡7 x ¿8 x «9 4189 4173 \end{lstlisting} 4190 4174 %$ … … 4199 4183 \end{lstlisting} 4200 4184 \item 4201 A seperator does not appear before or after a C string begining/ending with the characters: \lstinline[showspaces=true]@\`'" \f\n\r\t\v@4185 A seperator does not appear before or after a C string begining/ending with the \Index{ASCII} quote or whitespace characters: \lstinline[showspaces=true]@`'" \t\v\f\r\n@ 4202 4186 \begin{lstlisting}[belowskip=0pt] 4203 sout  "x\`"  1  "\`x'"  2  "'x\""  3  "\"x"  "x "  4  " x"  endl; 4204 \end{lstlisting} 4205 \begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] 4206 x\`1\`x'2'x"3"x x 4 x 4207 \end{lstlisting} 4208 \begin{lstlisting}[showtabs=true,aboveskip=0pt] 4209 sout  "x\t"  1  "\tx"  endl; 4210 x 1 x 4187 sout  "x`"  1  "`x'"  2  "'x\""  3  "\"x"  "x "  4  " x"  "x\t"  1  "\tx"  endl; 4188 \end{lstlisting} 4189 \begin{lstlisting}[mathescape=off,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt] 4190 x`1`x'2'x"3"x x 4 x x 1 x 4211 4191 \end{lstlisting} 4212 4192 \end{enumerate} … … 4260 4240 sout  '1'  '2'  '3'  endl; 4261 4241 sout  1  ""  2  ""  3  endl; 4262 sout  "x ("  1  "x ["  2  "x {"  3  "x $"  4  "x £"  5  "x ¥"  6  "x ¿"  7  "x «"  8 endl;4242 sout  "x ("  1  "x ["  2  "x {"  3  "x $"  4  "x £"  5  "x ¥"  6  "x ¡"  7  "x ¿"  8  "x «"  9  endl; 4263 4243 sout  1  ", x"  2  ". x"  3  ": x"  4  "; x"  5  "! x"  6  "? x"  7  ") x"  8  "] x"  9  "} x" 4264 4244  10  "% x"  11  "¢ x"  12  "» x"  endl; 4265 sout  "x`"  1  "`x'"  2  "'x\""  3  "\"x"  "x "  4  " x"  endl; 4266 sout  "x\t"  1  "\tx"  endl; 4245 sout  "x`"  1  "`x'"  2  "'x\""  3  "\"x"  "x "  4  " x"  "x\t"  1  "\tx"  endl; 4267 4246 sout  sepOn  1  2  3  sepOn  endl; // separator at start of line 4268 4247 sout  1  sepOff  2  3  endl; // turn off implicit separator temporarily … … 4290 4269 \subsection{malloc} 4291 4270 4292 \begin{lstlisting} [escapechar=^]4293 forall( otype T ) T * malloc( void ); ^\indexc{malloc}^4271 \begin{lstlisting} 4272 forall( otype T ) T * malloc( void );§\indexc{malloc}§ 4294 4273 forall( otype T ) T * malloc( char fill ); 4295 4274 forall( otype T ) T * malloc( T * ptr, size_t size ); 4296 4275 forall( otype T ) T * malloc( T * ptr, size_t size, unsigned char fill ); 4297 forall( otype T ) T * calloc( size_t nmemb ); ^\indexc{calloc}^4298 forall( otype T ) T * realloc( T * ptr, size_t size ); ^\indexc{ato}^4276 forall( otype T ) T * calloc( size_t nmemb );§\indexc{calloc}§ 4277 forall( otype T ) T * realloc( T * ptr, size_t size );§\indexc{ato}§ 4299 4278 forall( otype T ) T * realloc( T * ptr, size_t size, unsigned char fill ); 4300 4279 4301 forall( otype T ) T * aligned_alloc( size_t alignment ); ^\indexc{ato}^4280 forall( otype T ) T * aligned_alloc( size_t alignment );§\indexc{ato}§ 4302 4281 forall( otype T ) T * memalign( size_t alignment ); // deprecated 4303 4282 forall( otype T ) int posix_memalign( T ** ptr, size_t alignment ); … … 4310 4289 \subsection{ato / strto} 4311 4290 4312 \begin{lstlisting} [escapechar=^]4313 int ato( const char * ptr ); ^\indexc{ato}^4291 \begin{lstlisting} 4292 int ato( const char * ptr );§\indexc{ato}§ 4314 4293 unsigned int ato( const char * ptr ); 4315 4294 long int ato( const char * ptr ); … … 4341 4320 \subsection{bsearch / qsort} 4342 4321 4343 \begin{lstlisting} [escapechar=^]4322 \begin{lstlisting} 4344 4323 forall( otype T  { int ?<?( T, T ); } ) 4345 T * bsearch( const T key, const T * arr, size_t dimension ); ^\indexc{bsearch}^4324 T * bsearch( const T key, const T * arr, size_t dimension );§\indexc{bsearch}§ 4346 4325 4347 4326 forall( otype T  { int ?<?( T, T ); } ) 4348 void qsort( const T * arr, size_t dimension ); ^\indexc{qsort}^4327 void qsort( const T * arr, size_t dimension );§\indexc{qsort}§ 4349 4328 \end{lstlisting} 4350 4329 … … 4352 4331 \subsection{abs} 4353 4332 4354 \begin{lstlisting} [escapechar=^]4355 char abs( char ); ^\indexc{abs}^4333 \begin{lstlisting} 4334 char abs( char );§\indexc{abs}§ 4356 4335 int abs( int ); 4357 4336 long int abs( long int ); … … 4368 4347 \subsection{random} 4369 4348 4370 \begin{lstlisting} [escapechar=^]4371 void rand48seed( long int s ); ^\indexc{rand48seed}^4372 char rand48(); ^\indexc{rand48}^4349 \begin{lstlisting} 4350 void rand48seed( long int s );§\indexc{rand48seed}§ 4351 char rand48();§\indexc{rand48}§ 4373 4352 int rand48(); 4374 4353 unsigned int rand48(); … … 4385 4364 \subsection{min / max / swap} 4386 4365 4387 \begin{lstlisting} [escapechar=^]4366 \begin{lstlisting} 4388 4367 forall( otype T  { int ?<?( T, T ); } ) 4389 T min( const T t1, const T t2 ); ^\indexc{min}^4368 T min( const T t1, const T t2 );§\indexc{min}§ 4390 4369 4391 4370 forall( otype T  { int ?>?( T, T ); } ) 4392 T max( const T t1, const T t2 ); ^\indexc{max}^4371 T max( const T t1, const T t2 );§\indexc{max}§ 4393 4372 4394 4373 forall( otype T ) 4395 void swap( T * t1, T * t2 ); ^\indexc{swap}^4374 void swap( T * t1, T * t2 );§\indexc{swap}§ 4396 4375 \end{lstlisting} 4397 4376 … … 4405 4384 \subsection{General} 4406 4385 4407 \begin{lstlisting} [escapechar=^]4408 float fabs( float ); ^\indexc{fabs}^4386 \begin{lstlisting} 4387 float fabs( float );§\indexc{fabs}§ 4409 4388 double fabs( double ); 4410 4389 long double fabs( long double ); … … 4413 4392 long double cabs( long double _Complex ); 4414 4393 4415 float ?%?( float, float ); ^\indexc{fmod}^4394 float ?%?( float, float );§\indexc{fmod}§ 4416 4395 float fmod( float, float ); 4417 4396 double ?%?( double, double ); … … 4420 4399 long double fmod( long double, long double ); 4421 4400 4422 float remainder( float, float ); ^\indexc{remainder}^4401 float remainder( float, float );§\indexc{remainder}§ 4423 4402 double remainder( double, double ); 4424 4403 long double remainder( long double, long double ); 4425 4404 4426 [ int, float ] remquo( float, float ); ^\indexc{remquo}^4405 [ int, float ] remquo( float, float );§\indexc{remquo}§ 4427 4406 float remquo( float, float, int * ); 4428 4407 [ int, double ] remquo( double, double ); … … 4432 4411 4433 4412 [ int, float ] div( float, float ); // alternative name for remquo 4434 float div( float, float, int * ); ^\indexc{div}^4413 float div( float, float, int * );§\indexc{div}§ 4435 4414 [ int, double ] div( double, double ); 4436 4415 double div( double, double, int * ); … … 4438 4417 long double div( long double, long double, int * ); 4439 4418 4440 float fma( float, float, float ); ^\indexc{fma}^4419 float fma( float, float, float );§\indexc{fma}§ 4441 4420 double fma( double, double, double ); 4442 4421 long double fma( long double, long double, long double ); 4443 4422 4444 float fdim( float, float ); ^\indexc{fdim}^4423 float fdim( float, float );§\indexc{fdim}§ 4445 4424 double fdim( double, double ); 4446 4425 long double fdim( long double, long double ); 4447 4426 4448 float nan( const char * ); ^\indexc{nan}^4427 float nan( const char * );§\indexc{nan}§ 4449 4428 double nan( const char * ); 4450 4429 long double nan( const char * ); … … 4454 4433 \subsection{Exponential} 4455 4434 4456 \begin{lstlisting} [escapechar=^]4457 float exp( float ); ^\indexc{exp}^4435 \begin{lstlisting} 4436 float exp( float );§\indexc{exp}§ 4458 4437 double exp( double ); 4459 4438 long double exp( long double ); … … 4462 4441 long double _Complex exp( long double _Complex ); 4463 4442 4464 float exp2( float ); ^\indexc{exp2}^4443 float exp2( float );§\indexc{exp2}§ 4465 4444 double exp2( double ); 4466 4445 long double exp2( long double ); … … 4469 4448 long double _Complex exp2( long double _Complex ); 4470 4449 4471 float expm1( float ); ^\indexc{expm1}^4450 float expm1( float );§\indexc{expm1}§ 4472 4451 double expm1( double ); 4473 4452 long double expm1( long double ); 4474 4453 4475 float log( float ); ^\indexc{log}^4454 float log( float );§\indexc{log}§ 4476 4455 double log( double ); 4477 4456 long double log( long double ); … … 4480 4459 long double _Complex log( long double _Complex ); 4481 4460 4482 float log2( float ); ^\indexc{log2}^4461 float log2( float );§\indexc{log2}§ 4483 4462 double log2( double ); 4484 4463 long double log2( long double ); … … 4487 4466 long double _Complex log2( long double _Complex ); 4488 4467 4489 float log10( float ); ^\indexc{log10}^4468 float log10( float );§\indexc{log10}§ 4490 4469 double log10( double ); 4491 4470 long double log10( long double ); … … 4494 4473 long double _Complex log10( long double _Complex ); 4495 4474 4496 float log1p( float ); ^\indexc{log1p}^4475 float log1p( float );§\indexc{log1p}§ 4497 4476 double log1p( double ); 4498 4477 long double log1p( long double ); 4499 4478 4500 int ilogb( float ); ^\indexc{ilogb}^4479 int ilogb( float );§\indexc{ilogb}§ 4501 4480 int ilogb( double ); 4502 4481 int ilogb( long double ); 4503 4482 4504 float logb( float ); ^\indexc{logb}^4483 float logb( float );§\indexc{logb}§ 4505 4484 double logb( double ); 4506 4485 long double logb( long double ); … … 4510 4489 \subsection{Power} 4511 4490 4512 \begin{lstlisting} [escapechar=^]4513 float sqrt( float ); ^\indexc{sqrt}^4491 \begin{lstlisting} 4492 float sqrt( float );§\indexc{sqrt}§ 4514 4493 double sqrt( double ); 4515 4494 long double sqrt( long double ); … … 4518 4497 long double _Complex sqrt( long double _Complex ); 4519 4498 4520 float cbrt( float ); ^\indexc{cbrt}^4499 float cbrt( float );§\indexc{cbrt}§ 4521 4500 double cbrt( double ); 4522 4501 long double cbrt( long double ); 4523 4502 4524 float hypot( float, float ); ^\indexc{hypot}^4503 float hypot( float, float );§\indexc{hypot}§ 4525 4504 double hypot( double, double ); 4526 4505 long double hypot( long double, long double ); 4527 4506 4528 float pow( float, float ); ^\indexc{pow}^4507 float pow( float, float );§\indexc{pow}§ 4529 4508 double pow( double, double ); 4530 4509 long double pow( long double, long double ); … … 4537 4516 \subsection{Trigonometric} 4538 4517 4539 \begin{lstlisting} [escapechar=^]4540 float sin( float ); ^\indexc{sin}^4518 \begin{lstlisting} 4519 float sin( float );§\indexc{sin}§ 4541 4520 double sin( double ); 4542 4521 long double sin( long double ); … … 4545 4524 long double _Complex sin( long double _Complex ); 4546 4525 4547 float cos( float ); ^\indexc{cos}^4526 float cos( float );§\indexc{cos}§ 4548 4527 double cos( double ); 4549 4528 long double cos( long double ); … … 4552 4531 long double _Complex cos( long double _Complex ); 4553 4532 4554 float tan( float ); ^\indexc{tan}^4533 float tan( float );§\indexc{tan}§ 4555 4534 double tan( double ); 4556 4535 long double tan( long double ); … … 4559 4538 long double _Complex tan( long double _Complex ); 4560 4539 4561 float asin( float ); ^\indexc{asin}^4540 float asin( float );§\indexc{asin}§ 4562 4541 double asin( double ); 4563 4542 long double asin( long double ); … … 4566 4545 long double _Complex asin( long double _Complex ); 4567 4546 4568 float acos( float ); ^\indexc{acos}^4547 float acos( float );§\indexc{acos}§ 4569 4548 double acos( double ); 4570 4549 long double acos( long double ); … … 4573 4552 long double _Complex acos( long double _Complex ); 4574 4553 4575 float atan( float ); ^\indexc{atan}^4554 float atan( float );§\indexc{atan}§ 4576 4555 double atan( double ); 4577 4556 long double atan( long double ); … … 4580 4559 long double _Complex atan( long double _Complex ); 4581 4560 4582 float atan2( float, float ); ^\indexc{atan2}^4561 float atan2( float, float );§\indexc{atan2}§ 4583 4562 double atan2( double, double ); 4584 4563 long double atan2( long double, long double ); 4585 4564 4586 4565 float atan( float, float ); // alternative name for atan2 4587 double atan( double, double ); ^\indexc{atan}^4566 double atan( double, double );§\indexc{atan}§ 4588 4567 long double atan( long double, long double ); 4589 4568 \end{lstlisting} … … 4592 4571 \subsection{Hyperbolic} 4593 4572 4594 \begin{lstlisting} [escapechar=^]4595 float sinh( float ); ^\indexc{sinh}^4573 \begin{lstlisting} 4574 float sinh( float );§\indexc{sinh}§ 4596 4575 double sinh( double ); 4597 4576 long double sinh( long double ); … … 4600 4579 long double _Complex sinh( long double _Complex ); 4601 4580 4602 float cosh( float ); ^\indexc{cosh}^4581 float cosh( float );§\indexc{cosh}§ 4603 4582 double cosh( double ); 4604 4583 long double cosh( long double ); … … 4607 4586 long double _Complex cosh( long double _Complex ); 4608 4587 4609 float tanh( float ); ^\indexc{tanh}^4588 float tanh( float );§\indexc{tanh}§ 4610 4589 double tanh( double ); 4611 4590 long double tanh( long double ); … … 4614 4593 long double _Complex tanh( long double _Complex ); 4615 4594 4616 float asinh( float ); ^\indexc{asinh}^4595 float asinh( float );§\indexc{asinh}§ 4617 4596 double asinh( double ); 4618 4597 long double asinh( long double ); … … 4621 4600 long double _Complex asinh( long double _Complex ); 4622 4601 4623 float acosh( float ); ^\indexc{acosh}^4602 float acosh( float );§\indexc{acosh}§ 4624 4603 double acosh( double ); 4625 4604 long double acosh( long double ); … … 4628 4607 long double _Complex acosh( long double _Complex ); 4629 4608 4630 float atanh( float ); ^\indexc{atanh}^4609 float atanh( float );§\indexc{atanh}§ 4631 4610 double atanh( double ); 4632 4611 long double atanh( long double ); … … 4639 4618 \subsection{Error / Gamma} 4640 4619 4641 \begin{lstlisting} [escapechar=^]4642 float erf( float ); ^\indexc{erf}^4620 \begin{lstlisting} 4621 float erf( float );§\indexc{erf}§ 4643 4622 double erf( double ); 4644 4623 long double erf( long double ); … … 4647 4626 long double _Complex erf( long double _Complex ); 4648 4627 4649 float erfc( float ); ^\indexc{erfc}^4628 float erfc( float );§\indexc{erfc}§ 4650 4629 double erfc( double ); 4651 4630 long double erfc( long double ); … … 4654 4633 long double _Complex erfc( long double _Complex ); 4655 4634 4656 float lgamma( float ); ^\indexc{lgamma}^4635 float lgamma( float );§\indexc{lgamma}§ 4657 4636 double lgamma( double ); 4658 4637 long double lgamma( long double ); … … 4661 4640 long double lgamma( long double, int * ); 4662 4641 4663 float tgamma( float ); ^\indexc{tgamma}^4642 float tgamma( float );§\indexc{tgamma}§ 4664 4643 double tgamma( double ); 4665 4644 long double tgamma( long double ); … … 4669 4648 \subsection{Nearest Integer} 4670 4649 4671 \begin{lstlisting} [escapechar=^]4672 float floor( float ); ^\indexc{floor}^4650 \begin{lstlisting} 4651 float floor( float );§\indexc{floor}§ 4673 4652 double floor( double ); 4674 4653 long double floor( long double ); 4675 4654 4676 float ceil( float ); ^\indexc{ceil}^4655 float ceil( float );§\indexc{ceil}§ 4677 4656 double ceil( double ); 4678 4657 long double ceil( long double ); 4679 4658 4680 float trunc( float ); ^\indexc{trunc}^4659 float trunc( float );§\indexc{trunc}§ 4681 4660 double trunc( double ); 4682 4661 long double trunc( long double ); 4683 4662 4684 float rint( float ); ^\indexc{rint}^4663 float rint( float );§\indexc{rint}§ 4685 4664 long double rint( long double ); 4686 4665 long int rint( float ); … … 4691 4670 long long int rint( long double ); 4692 4671 4693 long int lrint( float ); ^\indexc{lrint}^4672 long int lrint( float );§\indexc{lrint}§ 4694 4673 long int lrint( double ); 4695 4674 long int lrint( long double ); … … 4698 4677 long long int llrint( long double ); 4699 4678 4700 float nearbyint( float ); ^\indexc{nearbyint}^4679 float nearbyint( float );§\indexc{nearbyint}§ 4701 4680 double nearbyint( double ); 4702 4681 long double nearbyint( long double ); 4703 4682 4704 float round( float ); ^\indexc{round}^4683 float round( float );§\indexc{round}§ 4705 4684 long double round( long double ); 4706 4685 long int round( float ); … … 4711 4690 long long int round( long double ); 4712 4691 4713 long int lround( float ); ^\indexc{lround}^4692 long int lround( float );§\indexc{lround}§ 4714 4693 long int lround( double ); 4715 4694 long int lround( long double ); … … 4722 4701 \subsection{Manipulation} 4723 4702 4724 \begin{lstlisting} [escapechar=^]4725 float copysign( float, float ); ^\indexc{copysign}^4703 \begin{lstlisting} 4704 float copysign( float, float );§\indexc{copysign}§ 4726 4705 double copysign( double, double ); 4727 4706 long double copysign( long double, long double ); 4728 4707 4729 float frexp( float, int * ); ^\indexc{frexp}^4708 float frexp( float, int * );§\indexc{frexp}§ 4730 4709 double frexp( double, int * ); 4731 4710 long double frexp( long double, int * ); 4732 4711 4733 float ldexp( float, int ); ^\indexc{ldexp}^4712 float ldexp( float, int );§\indexc{ldexp}§ 4734 4713 double ldexp( double, int ); 4735 4714 long double ldexp( long double, int ); 4736 4715 4737 [ float, float ] modf( float ); ^\indexc{modf}^4716 [ float, float ] modf( float );§\indexc{modf}§ 4738 4717 float modf( float, float * ); 4739 4718 [ double, double ] modf( double ); … … 4742 4721 long double modf( long double, long double * ); 4743 4722 4744 float nextafter( float, float ); ^\indexc{nextafter}^4723 float nextafter( float, float );§\indexc{nextafter}§ 4745 4724 double nextafter( double, double ); 4746 4725 long double nextafter( long double, long double ); 4747 4726 4748 float nexttoward( float, long double ); ^\indexc{nexttoward}^4727 float nexttoward( float, long double );§\indexc{nexttoward}§ 4749 4728 double nexttoward( double, long double ); 4750 4729 long double nexttoward( long double, long double ); 4751 4730 4752 float scalbn( float, int ); ^\indexc{scalbn}^4731 float scalbn( float, int );§\indexc{scalbn}§ 4753 4732 double scalbn( double, int ); 4754 4733 long double scalbn( long double, int ); 4755 4734 4756 float scalbln( float, long int ); ^\indexc{scalbln}^4735 float scalbln( float, long int );§\indexc{scalbln}§ 4757 4736 double scalbln( double, long int ); 4758 4737 long double scalbln( long double, long int ); … … 4766 4745 When creating and computing with rational numbers, results are constantly reduced to keep the numerator and denominator as small as possible. 4767 4746 4768 \begin{lstlisting} [escapechar=^]4747 \begin{lstlisting} 4769 4748 // implementation 4770 struct Rational { ^\indexc{Rational}^4749 struct Rational {§\indexc{Rational}§ 4771 4750 long int numerator, denominator; // invariant: denominator > 0 4772 4751 }; // Rational
Note: See TracChangeset
for help on using the changeset viewer.