Changeset 134e6d9


Ignore:
Timestamp:
Jun 5, 2023, 10:17:25 PM (12 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ast-experimental, master
Children:
874b16e
Parents:
b9fe89b
Message:

miscellaneous updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    rb9fe89b r134e6d9  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Mon Aug 22 23:43:30 2022
    14 %% Update Count     : 5503
     13%% Last Modified On : Mon Jun  5 21:18:29 2023
     14%% Update Count     : 5521
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    108108\huge \CFA Team (past and present) \medskip \\
    109109\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 Zulfiqar
     110\Large Glen Ditchfield, Rodolfo G. Esteves, Jiada Liang, Aaron Moss, Colby Parsons \smallskip \\
     111\Large Rob Schluntz, Fangren Yu, Mubeen Zulfiqar
    112112}% author
    113113
     
    169169Like \Index*[C++]{\CC{}}, there may be both old and new ways to achieve the same effect.
    170170For 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}}   \\
    174174\begin{cfa}[tabsize=3]
    175175#include <stdio.h>$\indexc{stdio.h}$
     
    199199\end{cfa}
    200200\end{tabular}
    201 \end{flushleft}
     201\end{center}
    202202While \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}.
    203203
     
    856856still works.
    857857Nevertheless, 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:
     858Therefore, 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:
    859859\begin{cfa}
    860860®choose® ( i ) {
     
    11671167\end{cfa}
    11681168\end{itemize}
    1169 \R{Warning}: specifying the down-to range maybe unexcepted 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):
    11701170\begin{cfa}
    11711171for ( i; 1 ~ 10 )       ${\C[1.5in]{// up range}$
     
    11731173for ( i; ®10 -~ 1® )    ${\C{// \R{WRONG down range!}}\CRT}$
    11741174\end{cfa}
    1175 The reason for this sematics 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.
     1175The 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.
    11761176
    11771177
     
    22562256Days days = Mon; // enumeration type declaration and initialization
    22572257\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}
     2258The set of enums is injected into the variable namespace at the definition scope.
     2259Hence, enums may be overloaded with variable, enum, and function names.
     2260\begin{cfa}
     2261int Foo;                        $\C{// type/variable separate namespaces}$
    22612262enum Foo { Bar };
    22622263enum Goo { Bar };       $\C[1.75in]{// overload Foo.Bar}$
    2263 int Foo;                        $\C{// type/variable separate namespace}$
    22642264double Bar;                     $\C{// overload Foo.Bar, Goo.Bar}\CRT$
    22652265\end{cfa}
     
    23012301Hence, the value of enum ©Mon© is 0, ©Tue© is 1, ...\,, ©Sun© is 6.
    23022302If an enum value is specified, numbering continues by one from that value for subsequent unnumbered enums.
    2303 If an enum value is an expression, the compiler performs constant-folding to obtain a constant value.
     2303If an enum value is a \emph{constant} expression, the compiler performs constant-folding to obtain a constant value.
    23042304
    23052305\CFA allows other integral types with associated values.
     
    23132313\begin{cfa}
    23142314// non-integral numeric
    2315 enum( ®double® ) Math { PI_2 = 1.570796, PI = 3.141597,  E = 2.718282 }
     2315enum( ®double® ) Math { PI_2 = 1.570796, PI = 3.141597, E = 2.718282 }
    23162316// pointer
    2317 enum( ®char *® ) Name { Fred = "Fred",  Mary = "Mary",  Jane = "Jane" };
     2317enum( ®char *® ) Name { Fred = "Fred",  Mary = "Mary", Jane = "Jane" };
    23182318int i, j, k;
    23192319enum( ®int *® ) ptr { I = &i,  J = &j,  K = &k };
    2320 enum( ®int &® ) ref { I = i,  J = j,  K = k };
     2320enum( ®int &® ) ref { I = i,   J = j,   K = k };
    23212321// tuple
    23222322enum( ®[int, int]® ) { T = [ 1, 2 ] };
     
    23612361\begin{cfa}
    23622362enum( char * ) Name2 { ®inline Name®, Jack = "Jack", Jill = "Jill" };
    2363 enum ®/* inferred */®  Name3 { ®inline Name2®, Sue = "Sue", Tom = "Tom" };
     2363enum ®/* inferred */® Name3 { ®inline Name2®, Sue = "Sue", Tom = "Tom" };
    23642364\end{cfa}
    23652365Enumeration ©Name2© inherits all the enums and their values from enumeration ©Name© by containment, and a ©Name© enumeration is a subtype of enumeration ©Name2©.
     
    38183818                                   "[ output-file (default stdout) ] ]";
    38193819                } // choose
    3820         } catch( ®Open_Failure® * ex; ex->istream == &in ) {
     3820        } catch( ®open_failure® * ex; ex->istream == &in ) { $\C{// input file errors}$
    38213821                ®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}$
    38233823                ®close®( in );                                          $\C{// optional}$
    38243824                ®exit® | "Unable to open output file" | argv[2];
     
    40384038
    40394039\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.
    40414041\begin{cfa}[belowskip=0pt]
    40424042sout | sepDisable | 1 | 2 | 3; $\C{// turn off implicit separator}$
     
    40534053
    40544054\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.
    40564056\begin{cfa}[belowskip=0pt]
    40574057sout | 1 | sepOff | 2 | 3; $\C{// turn off implicit separator for the next item}$
     
    412941296
    41304130\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 to print a single newline
     4131Note, 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
    41324132\item
    41334133\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.