- Timestamp:
- Jun 5, 2023, 10:17:25 PM (19 months ago)
- Branches:
- ast-experimental, master
- Children:
- 874b16e
- Parents:
- b9fe89b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/user/user.tex
rb9fe89b r134e6d9 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Mon Aug 22 23:43:30 202214 %% Update Count : 55 0313 %% Last Modified On : Mon Jun 5 21:18:29 2023 14 %% Update Count : 5521 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 108 108 \huge \CFA Team (past and present) \medskip \\ 109 109 \Large Andrew Beach, Richard Bilson, Michael Brooks, Peter A. Buhr, Thierry Delisle, \smallskip \\ 110 \Large Glen Ditchfield, Rodolfo G. Esteves, Aaron Moss, Colby Parsons, Rob Schluntz,\smallskip \\111 \Large Fangren Yu, Mubeen Zulfiqar110 \Large Glen Ditchfield, Rodolfo G. Esteves, Jiada Liang, Aaron Moss, Colby Parsons \smallskip \\ 111 \Large Rob Schluntz, Fangren Yu, Mubeen Zulfiqar 112 112 }% author 113 113 … … 169 169 Like \Index*[C++]{\CC{}}, there may be both old and new ways to achieve the same effect. 170 170 For example, the following programs compare the C, \CFA, and \CC I/O mechanisms, where the programs output the same result. 171 \begin{ flushleft}172 \begin{tabular}{@{}l @{\hspace{1em}}l@{\hspace{1em}}l@{}}173 \multicolumn{1}{@{}c @{\hspace{1em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} & \multicolumn{1}{c@{}}{\textbf{\CC}} \\171 \begin{center} 172 \begin{tabular}{@{}lll@{}} 173 \multicolumn{1}{@{}c}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} & \multicolumn{1}{c@{}}{\textbf{\CC}} \\ 174 174 \begin{cfa}[tabsize=3] 175 175 #include <stdio.h>$\indexc{stdio.h}$ … … 199 199 \end{cfa} 200 200 \end{tabular} 201 \end{ flushleft}201 \end{center} 202 202 While \CFA I/O \see{\VRef{s:StreamIOLibrary}} looks similar to \Index*[C++]{\CC{}}, there are important differences, such as automatic spacing between variables and an implicit newline at the end of the expression list, similar to \Index*{Python}~\cite{Python}. 203 203 … … 856 856 still works. 857 857 Nevertheless, reversing the default action would have a non-trivial effect on case actions that compound, such as the above example of processing shell arguments. 858 Therefore, to preserve backwards compatibility, it is necessary to introduce a new kind of ©switch© statement, called \Indexc{choose}, with no implicit fall-through semantics and an explicit fall-through if the last statement of a case-clause ends with the new keyword \Indexc{fallthrough}/\ Indexc{fallthru}, \eg:858 Therefore, to preserve backwards compatibility, it is necessary to introduce a new kind of ©switch© statement, called \Indexc{choose}, with no implicit fall-through semantics and an explicit fall-through if the last statement of a case-clause ends with the new keyword \Indexc{fallthrough}/\-\Indexc{fallthru}, \eg: 859 859 \begin{cfa} 860 860 ®choose® ( i ) { … … 1167 1167 \end{cfa} 1168 1168 \end{itemize} 1169 \R{Warning}: specifying the down-to range maybe unex cepted because the loop control \emph{implicitly} switches the L and H values (and toggles the increment/decrement for I):1169 \R{Warning}: specifying the down-to range maybe unexpected because the loop control \emph{implicitly} switches the L and H values (and toggles the increment/decrement for I): 1170 1170 \begin{cfa} 1171 1171 for ( i; 1 ~ 10 ) ${\C[1.5in]{// up range}$ … … 1173 1173 for ( i; ®10 -~ 1® ) ${\C{// \R{WRONG down range!}}\CRT}$ 1174 1174 \end{cfa} 1175 The reason for this sema tics is that the range direction can be toggled by adding/removing the minus, ©'-'©, versus interchanging the L and H expressions, which has a greater chance of introducing errors.1175 The reason for this semantics is that the range direction can be toggled by adding/removing the minus, ©'-'©, versus interchanging the L and H expressions, which has a greater chance of introducing errors. 1176 1176 1177 1177 … … 2256 2256 Days days = Mon; // enumeration type declaration and initialization 2257 2257 \end{cfa} 2258 The set of enums are injected into the variable namespace at the definition scope. 2259 Hence, enums may be overloaded with enum/variable/function names. 2260 \begin{cfa} 2258 The set of enums is injected into the variable namespace at the definition scope. 2259 Hence, enums may be overloaded with variable, enum, and function names. 2260 \begin{cfa} 2261 int Foo; $\C{// type/variable separate namespaces}$ 2261 2262 enum Foo { Bar }; 2262 2263 enum Goo { Bar }; $\C[1.75in]{// overload Foo.Bar}$ 2263 int Foo; $\C{// type/variable separate namespace}$2264 2264 double Bar; $\C{// overload Foo.Bar, Goo.Bar}\CRT$ 2265 2265 \end{cfa} … … 2301 2301 Hence, the value of enum ©Mon© is 0, ©Tue© is 1, ...\,, ©Sun© is 6. 2302 2302 If an enum value is specified, numbering continues by one from that value for subsequent unnumbered enums. 2303 If an enum value is a nexpression, the compiler performs constant-folding to obtain a constant value.2303 If an enum value is a \emph{constant} expression, the compiler performs constant-folding to obtain a constant value. 2304 2304 2305 2305 \CFA allows other integral types with associated values. … … 2313 2313 \begin{cfa} 2314 2314 // non-integral numeric 2315 enum( ®double® ) Math { PI_2 = 1.570796, PI = 3.141597, 2315 enum( ®double® ) Math { PI_2 = 1.570796, PI = 3.141597, E = 2.718282 } 2316 2316 // pointer 2317 enum( ®char *® ) Name { Fred = "Fred", Mary = "Mary", 2317 enum( ®char *® ) Name { Fred = "Fred", Mary = "Mary", Jane = "Jane" }; 2318 2318 int i, j, k; 2319 2319 enum( ®int *® ) ptr { I = &i, J = &j, K = &k }; 2320 enum( ®int &® ) ref { I = i, J = j,K = k };2320 enum( ®int &® ) ref { I = i, J = j, K = k }; 2321 2321 // tuple 2322 2322 enum( ®[int, int]® ) { T = [ 1, 2 ] }; … … 2361 2361 \begin{cfa} 2362 2362 enum( char * ) Name2 { ®inline Name®, Jack = "Jack", Jill = "Jill" }; 2363 enum ®/* inferred */® 2363 enum ®/* inferred */® Name3 { ®inline Name2®, Sue = "Sue", Tom = "Tom" }; 2364 2364 \end{cfa} 2365 2365 Enumeration ©Name2© inherits all the enums and their values from enumeration ©Name© by containment, and a ©Name© enumeration is a subtype of enumeration ©Name2©. … … 3818 3818 "[ output-file (default stdout) ] ]"; 3819 3819 } // choose 3820 } catch( ® Open_Failure® * ex; ex->istream == &in ) {3820 } catch( ®open_failure® * ex; ex->istream == &in ) { $\C{// input file errors}$ 3821 3821 ®exit® | "Unable to open input file" | argv[1]; 3822 } catch( ® Open_Failure® * ex; ex->ostream == &out ) {3822 } catch( ®open_failure® * ex; ex->ostream == &out ) { $\C{// output file errors}$ 3823 3823 ®close®( in ); $\C{// optional}$ 3824 3824 ®exit® | "Unable to open output file" | argv[2]; … … 4038 4038 4039 4039 \item 4040 \Indexc{sepDisable}\index{manipulator!sepDisable@©sepDisable©} and \Indexc{sepEnable}\index{manipulator!sepEnable@©sepEnable©} toggle printing the separator.4040 \Indexc{sepDisable}\index{manipulator!sepDisable@©sepDisable©} and \Indexc{sepEnable}\index{manipulator!sepEnable@©sepEnable©} globally toggle printing the separator. 4041 4041 \begin{cfa}[belowskip=0pt] 4042 4042 sout | sepDisable | 1 | 2 | 3; $\C{// turn off implicit separator}$ … … 4053 4053 4054 4054 \item 4055 \Indexc{sepOn}\index{manipulator!sepOn@©sepOn©} and \Indexc{sepOff}\index{manipulator!sepOff@©sepOff©} toggle printing the separator with respect to the next printed item, and then return to the global separator setting.4055 \Indexc{sepOn}\index{manipulator!sepOn@©sepOn©} and \Indexc{sepOff}\index{manipulator!sepOff@©sepOff©} locally toggle printing the separator with respect to the next printed item, and then return to the global separator setting. 4056 4056 \begin{cfa}[belowskip=0pt] 4057 4057 sout | 1 | sepOff | 2 | 3; $\C{// turn off implicit separator for the next item}$ … … 4129 4129 6 4130 4130 \end{cfa} 4131 Note, a terminating ©nl© is merged (overrides) with the implicit newline at the end of the ©sout© expression, otherwise it is impossible to toprint a single newline4131 Note, a terminating ©nl© is merged (overrides) with the implicit newline at the end of the ©sout© expression, otherwise it is impossible to print a single newline 4132 4132 \item 4133 4133 \Indexc{nlOn}\index{manipulator!nlOn@©nlOn©} implicitly prints a newline at the end of each output expression.
Note: See TracChangeset
for help on using the changeset viewer.