Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    r0638c44 r6e991d6  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Tue May  3 08:05:33 2016
    14 %% Update Count     : 246
     13%% Last Modified On : Thu Apr 21 08:15:37 2016
     14%% Update Count     : 131
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
    1717% requires tex packages: texlive-base texlive-latex-base tex-common texlive-humanities texlive-latex-extra texlive-fonts-recommended
    18 
    19 % inline code ©...© (copyright symbol) emacs: C-q M-)
    20 % red highlighting ®...® (registered trademark sumbol) emacs: C-q M-.
    21 % latex escape §...§ (section symbol) emacs: C-q M-'
    22 % keyword escape ¶...¶ (pilcrow symbol) emacs: C-q M-^
    23 % math escape $...$ (dollar symbol)
    2418
    2519\documentclass[openright,twoside]{article}
     
    180174\CC~\cite{c++,ANSI14:C++} is an example of a similar project;
    181175however, it largely extended the language, and did not address existing problems.\footnote{%
    182 Two important existing problems addressed were changing the type of character literals from ©int© to ©char© and enumerator from ©int© to the type of its enumerators.}
     176Two important existing problems addressed were changing the type of character literals from \lstinline@int@ to \lstinline@char@ and enumerator from \lstinline@int@ to the type of its enumerators.}
    183177Fortran~\cite{Fortran08}, Ada~\cite{Ada12}, and Cobol~\cite{Cobol14} are examples of programming languages that took an evolutionary approach, where modern language features are added and problems fixed within the framework of the existing language.
    184178Java~\cite{Java8}, Go~\cite{Go}, Rust~\cite{Rust} and D~\cite{D} are examples of the revolutionary approach for modernizing C/\CC, resulting in a new language rather than an extension of the descendent.
     
    205199
    206200However, it is necessary to differentiate between C and \CFA code because of name overloading, as for \CC.
    207 For example, the C math-library provides the following routines for computing the absolute value of the basic type: ©abs©, ©labs©, ©llabs©, ©fabs©, ©fabsf©, ©fabsl©, ©cabsf©, ©cabs©, and ©cabsl©.
    208 Whereas, \CFA wraps each of these routines into one with the common name ©abs©.
     201For example, the C math-library provides the following routines for computing the absolute value of the basic type: \lstinline@abs@, \lstinline@labs@, \lstinline@llabs@, \lstinline@fabs@, \lstinline@fabsf@, \lstinline@fabsl@, \lstinline@cabsf@, \lstinline@cabs@, and \lstinline@cabsl@.
     202Whereas, \CFA wraps each of these routines into one with the common name \lstinline@abs@.
    209203\begin{lstlisting}
    210204char abs( char );
     
    221215long double _Complex abs( long double _Complex );
    222216\end{lstlisting}
    223 The problem is the name clash between the library routine ©abs© and the \CFA names ©abs©.
    224 Hence, names appearing in an ©extern "C"© block have \newterm{C linkage}.
     217The problem is the name clash between the library routine \lstinline@abs@ and the \CFA names \lstinline@abs@.
     218Hence, names appearing in an \lstinline@extern "C"@ block have \newterm{C linkage}.
    225219Then overloading polymorphism uses a mechanism called \newterm{name mangling} to create unique names that are different from C names, which are not mangled.
    226220Hence, there is the same need as in \CC, to know if a name is a C or \CFA name, so it can be correctly formed.
    227221There is no way around this problem, other than C's approach of creating unique names for each pairing of operation and type.
    228222This example strongly illustrates a core idea in \CFA: \emph{the power of a name}.
    229 The name ``©abs©'' evokes the notion of absolute value, and many mathematical types provide the notion of absolute value.
    230 Hence, knowing the name ©abs© should be sufficient to apply it to any type where it is applicable.
     223The name ``\lstinline@abs@'' evokes the notion of absolute value, and many mathematical types provide the notion of absolute value.
     224Hence, knowing the name \lstinline@abs@ should be sufficient to apply it to any type where it is applicable.
    231225The time savings and safety of using one name uniformly versus $N$ unique names should not be underestimated.
    232226
    233227
    234 \section[Compiling CFA Program]{Compiling \CFA Program}
    235 
    236 The command ©cfa© is used to compile \CFA program(s).
    237 This command works like the GNU ©gcc©\index{gcc} command, e.g.:
    238 \begin{lstlisting}
    239 cfa§\indexc{cfa}\index{compilation!cfa@©cfa©}§ [ gcc-options ] C/§\CFA§-files [ assembler/loader-files ]
    240 \end{lstlisting}
    241 By default, \CFA programs having the following ©gcc© flags turned on:
     228\section{Compiling \CFA Program}
     229
     230The command \lstinline@cfa@ is used to compile \CFA program(s).
     231This command works like the GNU \lstinline@gcc@\index{gcc} command, e.g.:
     232\begin{lstlisting}
     233cfa [ gcc-options ] C/@{\CFA}@-files [ assembler/loader-files ]
     234\end{lstlisting}
     235\index{cfa@\lstinline$cfa$}\index{compilation!cfa@\lstinline$cfa$}
     236By default, \CFA programs having the following \lstinline@gcc@ flags turned on:
    242237\begin{description}
    243 \item\hspace*{-4pt}\Indexc{-std=gnu99}\index{compilation option!-std=gnu99@{©-std=gnu99©}}
     238\item
     239\hspace*{-4pt}\lstinline@-std=gnu99@
     240\index{-std=gnu99@{\lstinline$-std=gnu99$}}\index{compilation option!-std=gnu99@{\lstinline$-std=gnu99$}}
    244241The 1999 C standard plus GNU extensions.
    245 \item\hspace*{-4pt}\Indexc{-fgnu89-¶inline¶}\index{compilation option!-fgnu89-inline@{©-fgnu89-¶inline¶©}}
     242\item
     243\hspace*{-4pt}\lstinline@-fgnu89-inline@
     244\index{-fgnu89-inline@{\lstinline$-fgnu89-inline$}}\index{compilation option!-fgnu89-inline@{\lstinline$-fgnu89-inline$}}
    246245Use the traditional GNU semantics for inline routines in C99 mode.
    247246\end{description}
    248247The following new \CFA option is available:
    249248\begin{description}
    250 \item\hspace*{-4pt}\Indexc{-CFA}\index{compilation option!-CFA@{©-CFA©}}
     249\item
     250\hspace*{-4pt}\lstinline@-CFA@
     251\index{-CFA@{\lstinline$-CFA$}}\index{compilation option!-CFA@{\lstinline$-CFA$}}
    251252Only 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.
    252253\end{description}
     
    254255The following preprocessor variables are available:
    255256\begin{description}
    256 \item\hspace*{-4pt}\Indexc{__CFA__}\index{preprocessor variables!__CFA__@{©__CFA__©}}
     257\item
     258\hspace*{-4pt}\lstinline$__CFA__$
     259\index{__CFA__@{\lstinline$__CFA__$}}\index{preprocessor variables!__CFA__@{\lstinline$__CFA__$}}
    257260is always available during preprocessing and its value is the current major \Index{version number} of \CFA.\footnote{
    258261The C preprocessor allows only integer values in a preprocessor variable so a value like ``\Version'' is not allowed.
    259262Hence, the need to have three variables for the major, minor and patch version number.}
    260263
    261 \item\hspace*{-4pt}\Indexc{__CFA_MINOR__}\index{preprocessor variables!__CFA_MINOR__@{©__CFA_MINOR__©}}
     264\item
     265\hspace*{-4pt}\lstinline$__CFA_MINOR__$
     266\index{__CFA_MINOR__@{\lstinline$__CFA_MINOR__$}}\index{preprocessor variables!__CFA_MINOR__@{\lstinline$__CFA_MINOR__$}}
    262267is always available during preprocessing and its value is the current minor \Index{version number} of \CFA.
    263268
    264 \item\hspace*{-4pt}\Indexc{__CFA_PATCH__}\index{preprocessor variables!__CFA_PATCH__@©__CFA_PATCH__©}
     269\item
     270\hspace*{-4pt}\lstinline$__CFA_PATCH__$
     271\index{__CFA_PATCH__@%(__CFA_PATCH__%)}\index{preprocessor variables!__CFA_PATCH__@%(__CFA_PATCH__%)}
    265272is always available during preprocessing and its value is the current patch \Index{version number} of \CFA.
    266273
    267 \item\hspace*{-4pt}\Indexc{__CFORALL__}\index{preprocessor variables!__CFORALL__@©__CFORALL__©}
     274\item
     275\hspace*{-4pt}\lstinline$__CFORALL__$
     276\index{__CFORALL__@%(__CFORALL__%)}\index{preprocessor variables!__CFORALL__@%(__CFORALL__%)}
    268277is always available during preprocessing and it has no value.
    269278\end{description}
     
    273282\begin{lstlisting}
    274283#ifndef __CFORALL__
    275 #include <stdio.h>                      // C header file
     284#include <stdio.h>              // C header file
    276285#else
    277 #include <fstream>                      // §\CFA{}§ header file
     286#include <fstream>              // @\CFA{}@ header file
    278287#endif
    279288\end{lstlisting}
    280 which conditionally includes the correct header file, if the program is compiled using ©gcc© or ©cfa©.
     289which conditionally includes the correct header file, if the program is compiled using \lstinline@gcc@ or \lstinline@cfa@.
    281290
    282291
     
    285294Numeric constants are extended to allow \Index{underscore}s within constants\index{constant!underscore}, e.g.:
    286295\begin{lstlisting}
    287 2®_®147®_®483®_®648;                            // decimal constant
     2962`_`147`_`483`_`648;                            // decimal constant
    28829756_ul;                                          // decimal unsigned long constant
    2892980_377;                                          // octal constant
     
    299308\begin{enumerate}
    300309\item
    301 A sequence of underscores is disallowed, e.g., ©12__34© is invalid.
     310A sequence of underscores is disallowed, e.g., \lstinline@12__34@ is invalid.
    302311\item
    303312Underscores may only appear within a sequence of digits (regardless of the digit radix).
    304 In other words, an underscore cannot start or end a sequence of digits, e.g., ©_1©, ©1_© and ©_1_© are invalid (actually, the 1st and 3rd examples are identifier names).
     313In other words, an underscore cannot start or end a sequence of digits, e.g., \lstinline@_1@, \lstinline@1_@ and \lstinline@_1_@ are invalid (actually, the 1st and 3rd examples are identifier names).
    305314\item
    306315A numeric prefix may end with an underscore;
    307316a numeric infix may begin and/or end with an underscore;
    308317a numeric suffix may begin with an underscore.
    309 For example, the octal ©0© or hexadecimal ©0x© prefix may end with an underscore ©0_377© or ©0x_ff©;
    310 the exponent infix ©E© may start or end with an underscore ©1.0_E10©, ©1.0E_10© or ©1.0_E_10©;
    311 the type suffixes ©U©, ©L©, etc. may start with an underscore ©1_U©, ©1_ll© or ©1.0E10_f©.
     318For example, the octal \lstinline@0@ or hexadecimal \lstinline@0x@ prefix may end with an underscore \lstinline@0_377@ or \lstinline@0x_ff@;
     319the exponent infix \lstinline@E@ may start or end with an underscore \lstinline@1.0_E10@, \lstinline@1.0E_10@ or \lstinline@1.0_E_10@;
     320the type suffixes \lstinline@U@, \lstinline@L@, etc. may start with an underscore \lstinline@1_U@, \lstinline@1_ll@ or \lstinline@1.0E10_f@.
    312321\end{enumerate}
    313322It is significantly easier to read and enter long constants when they are broken up into smaller groupings (most cultures use comma or period among digits for the same purpose).
     
    344353C and the new \CFA declarations may appear together in the same program block, but cannot be mixed within a specific declaration.
    345354
    346 In \CFA declarations, the same tokens are used as in C: the character ©*© is used to indicate a pointer, square brackets ©[©\,©]© are used to represent an array, and parentheses ©()© are used to indicate a routine parameter.
     355In \CFA declarations, the same tokens are used as in C: the character \lstinline@*@ is used to indicate a pointer, square brackets \lstinline@[@\,\lstinline@]@ are used to represent an array, and parentheses \lstinline@()@ are used to indicate a routine parameter.
    347356However, unlike C, \CFA type declaration tokens are specified from left to right and the entire type specification is distributed across all variables in the declaration list.
    348 For instance, variables ©x© and ©y© of type pointer to integer are defined in \CFA as follows:
     357For instance, variables \lstinline@x@ and \lstinline@y@ of type pointer to integer are defined in \CFA as follows:
    349358\begin{quote2}
    350359\begin{tabular}{@{}l@{\hspace{30pt}}l@{}}
    351360\multicolumn{1}{c@{\hspace{30pt}}}{\textbf{\CFA}}       & \multicolumn{1}{c}{\textbf{C}}        \\
    352361\begin{lstlisting}
    353 ®* int x, y;®
     362`* int x, y;`
    354363\end{lstlisting}
    355364&
     
    398407\end{quote2}
    399408
    400 All type qualifiers, i.e., ©const© and ©volatile©, are used in the normal way with the new declarations but appear left to right, e.g.:
     409All type qualifiers, i.e., \lstinline@const@ and \lstinline@volatile@, are used in the normal way with the new declarations but appear left to right, e.g.:
    401410\begin{quote2}
    402411\begin{tabular}{@{}l@{\hspace{30pt}}l@{\hspace{20pt}}l@{}}
     
    418427\end{tabular}
    419428\end{quote2}
    420 All declaration qualifiers, i.e., ©extern©, ©static©, etc., are used in the normal way with the new declarations but can only appear at the start of a \CFA routine declaration,\footnote{\label{StorageClassSpecifier}
     429All declaration qualifiers, i.e., \lstinline@extern@, \lstinline@static@, etc., are used in the normal way with the new declarations but can only appear at the start of a \CFA routine declaration,\footnote{\label{StorageClassSpecifier}
    421430The placement of a storage-class specifier other than at the beginning of the declaration specifiers in a declaration is an obsolescent feature.~\cite[\S~6.11.5(1)]{C11}} e.g.:
    422431\begin{quote2}
     
    440449\end{quote2}
    441450
    442 Unsupported are K\&R C declarations where the base type defaults to ©int©, if no type is specified\footnote{
     451Unsupported are K\&R C declarations where the base type defaults to \lstinline@int@, if no type is specified\footnote{
    443452At least one type specifier shall be given in the declaration specifiers in each declaration, and in the specifier-qualifier list in each structure declaration and type name~\cite[\S~6.7.2(2)]{C11}},
    444453e.g.:
     
    457466\section{Type Operators}
    458467
    459 The new declaration syntax can be used in other contexts where types are required, e.g., casts and the pseudo-routine ©sizeof©:
     468The new declaration syntax can be used in other contexts where types are required, e.g., casts and the pseudo-routine \lstinline@sizeof@:
    460469\begin{quote2}
    461470\begin{tabular}{@{}l@{\hspace{30pt}}l@{}}
     
    479488The point of the new syntax is to allow returning multiple values from a routine~\cite{CLU,Galletly96}, e.g.:
    480489\begin{lstlisting}
    481 ®[ int o1, int o2, char o3 ]® f( int i1, char i2, char i3 ) {
    482         §\emph{routine body}§
    483 }
    484 \end{lstlisting}
    485 where routine ©f© has three output (return values) and three input parameters.
     490`[ int o1, int o2, char o3 ]` f( int i1, char i2, char i3 ) {
     491        @\emph{routine body}@
     492}
     493\end{lstlisting}
     494where routine \lstinline@f@ has three output (return values) and three input parameters.
    486495Existing C syntax cannot be extended with multiple return types because it is impossible to embed a single routine name within multiple return type specifications.
    487496
    488 In detail, the brackets, ©[]©, enclose the result type, where each return value is named and that name is a local variable of the particular return type.\footnote{
     497In detail, the brackets, \lstinline@[]@, enclose the result type, where each return value is named and that name is a local variable of the particular return type.\footnote{
    489498Michael Tiemann, with help from Doug Lea, provided named return values in g++, circa 1989.}
    490499The value of each local return variable is automatically returned at routine termination.
    491500Declaration qualifiers can only appear at the start of a routine definition, e.g.:
    492501\begin{lstlisting}
    493 extern [ int x ] g( int y ) {§\,§}
     502extern [ int x ] g( int y ) {@\,@}
    494503\end{lstlisting}
    495504Lastly, if there are no output parameters or input parameters, the brackets and/or parentheses must still be specified;
    496505in 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:
    497506\begin{lstlisting}
    498 [§\,§] g();                                             // no input or output parameters
     507[@\,@] g(@\,@);                         // no input or output parameters
    499508[ void ] g( void );                     // no input or output parameters
    500509\end{lstlisting}
     
    510519int (*f(x))[ 5 ] int x; {}
    511520\end{lstlisting}
    512 The string ``©int (*f(x))[ 5 ]©'' declares a K\&R style routine of type returning a pointer to an array of 5 integers, while the string ``©[ 5 ] int x©'' declares a \CFA style parameter x of type array of 5 integers.
    513 Since the strings overlap starting with the open bracket, ©[©, there is an ambiguous interpretation for the string.
     521The string ``\lstinline@int (*f(x))[ 5 ]@'' declares a K\&R style routine of type returning a pointer to an array of 5 integers, while the string ``\lstinline@[ 5 ] int x@'' declares a \CFA style parameter x of type array of 5 integers.
     522Since the strings overlap starting with the open bracket, \lstinline@[@, there is an ambiguous interpretation for the string.
    514523As well, \CFA-style declarations cannot be used to declare parameters for C-style routine-definitions because of the following ambiguity:
    515524\begin{lstlisting}
     
    517526int f( int (* foo) );           // foo is redefined as a parameter name
    518527\end{lstlisting}
    519 The string ``©int (* foo)©'' declares a C-style named-parameter of type pointer to an integer (the parenthesis are superfluous), while the same string declares a \CFA style unnamed parameter of type routine returning integer with unnamed parameter of type pointer to foo.
    520 The redefinition of a type name in a parameter list is the only context in C where the character ©*© can appear to the left of a type name, and \CFA relies on all type modifier characters appearing to the right of the type name.
     528The string ``\lstinline@int (* foo)@'' declares a C-style named-parameter of type pointer to an integer (the parenthesis are superfluous), while the same string declares a \CFA style unnamed parameter of type routine returning integer with unnamed parameter of type pointer to foo.
     529The redefinition of a type name in a parameter list is the only context in C where the character \lstinline@*@ can appear to the left of a type name, and \CFA relies on all type modifier characters appearing to the right of the type name.
    521530The inability to use \CFA declarations in these two contexts is probably a blessing because it precludes programmers from arbitrarily switching between declarations forms within a declaration contexts.
    522531
     
    537546\subsection{Returning Values}
    538547
    539 Named return values handle the case where it is necessary to define a local variable whose value is then returned in a ©return© statement, as in:
     548Named return values handle the case where it is necessary to define a local variable whose value is then returned in a \lstinline@return@ statement, as in:
    540549\begin{lstlisting}
    541550int f() {
     
    545554}
    546555\end{lstlisting}
    547 Because the value in the return variable is automatically returned when a \CFA routine terminates, the ©return© statement \emph{does not} contain an expression, as in:
    548 \begin{lstlisting}
    549 ®[ int x ]® f() {
     556Because 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\begin{lstlisting}
     558`[ int x ]` f() {
    550559        ... x = 0; ... x = y; ...
    551         ®return;® // implicitly return x
    552 }
    553 \end{lstlisting}
    554 When the return is encountered, the current value of ©x© is returned to the calling routine.
    555 As well, ``falling off the end'' of a routine without a ©return© statement is permitted, as in:
     560        `return;` // implicitly return x
     561}
     562\end{lstlisting}
     563When the return is encountered, the current value of \lstinline@x@ is returned to the calling routine.
     564As well, ``falling off the end'' of a routine without a \lstinline@return@ statement is permitted, as in:
    556565\begin{lstlisting}
    557566[ int x ] f() {
     
    559568} // implicitly return x
    560569\end{lstlisting}
    561 In this case, the current value of ©x© is returned to the calling routine just as if a ©return© had been encountered.
     570In this case, the current value of \lstinline@x@ is returned to the calling routine just as if a \lstinline@return@ had been encountered.
    562571
    563572
     
    772781\subsection{Type Nesting}
    773782
    774 \CFA allows \Index{type nesting}, and type qualification of the nested types, where as C hoists\index{type hoisting} (refactors) nested types into the enclosing scope and has no type qualification.
     783\CFA allows \Index{type nesting}, and type qualification of the nested types, where as C hoists\index{type!hoisting} (refactors) nested types into the enclosing scope and has no type qualification.
    775784\begin{quote2}
    776785\begin{tabular}{@{}l@{\hspace{30pt}}l|l@{}}
     
    827836
    828837int fred() {
    829         s.t.c = ®S.®R;  // type qualification
    830         struct ®S.®T t = { ®S.®R, 1, 2 };
    831         enum ®S.®C c;
    832         union ®S.T.®U u;
     838        s.t.c = `S.`R;  // type qualification
     839        struct `S.`T t = { `S.`R, 1, 2 };
     840        enum `S.`C c;
     841        union `S.T.`U u;
    833842}
    834843\end{lstlisting}
    835844\end{tabular}
    836845\end{quote2}
    837 In the left example in C, types ©C©, ©U© and ©T© are implicitly hoisted outside of type ©S© into the containing block scope.
    838 In the right example in \CFA, the types are not hoisted and accessed using the field-selection operator ``©.©'' for type qualification, as does Java, rather than the \CC type-selection operator ``©::©''.
     846In the left example in C, types \lstinline@C@, \lstinline@U@ and \lstinline@T@ are implicitly hoisted outside of type \lstinline@S@ into the containing block scope.
     847In the right example in \CFA, the types are not hoisted and accessed using the field-selection operator ``\lstinline@.@'' for type qualification, as does Java, rather than the \CC type-selection operator ``\lstinline@::@''.
    839848
    840849
     
    854863qsort( ia, size );              // sort ascending order using builtin ?<?
    855864{
    856         ®int ?<?( int x, int y ) { return x > y; }® // nested routine
     865        `int ?<?( int x, int y ) { return x > y; }` // nested routine
    857866        qsort( ia, size );      // sort descending order by local redefinition
    858867}
     
    861870Nested routines are not first-class, meaning a nested routine cannot be returned if it has references to variables in its enclosing blocks;
    862871the only exception is references to the external block of the translation unit, as these variables persist for the duration of the program.
    863 The following program in undefined in \CFA (and ©gcc©\index{gcc})
     872The following program in undefined in \CFA (and \lstinline@gcc@\index{gcc})
    864873\begin{lstlisting}
    865874[* [int]( int )] foo() {                // int (*foo())( int )
    866         int ®i® = 7;
     875        int `i` = 7;
    867876        int bar( int p ) {
    868                 ®i® += 1;                                       // dependent on local variable
    869                 sout | ®i® | endl;
     877                `i` += 1;                                       // dependent on local variable
     878                sout | `i` | endl;
    870879        }
    871880        return bar;                                     // undefined because of local dependence
     
    888897The general syntax of a tuple is:
    889898\begin{lstlisting}
    890 [ §\emph{exprlist}§ ]
    891 \end{lstlisting}
    892 where ©$\emph{exprlist}$© is a list of one or more expressions separated by commas.
    893 The brackets, ©[]©, allow differentiating between tuples and expressions containing the C comma operator.
     899[ $\emph{exprlist}$ ]
     900\end{lstlisting}
     901where \lstinline@$\emph{exprlist}$@ is a list of one or more expressions separated by commas.
     902The brackets, \lstinline$[]$, allow differentiating between tuples and expressions containing the C comma operator.
    894903The following are examples of tuples:
    895904\begin{lstlisting}
     
    898907[ v+w, x*y, 3.14159, f() ]
    899908\end{lstlisting}
    900 Tuples are permitted to contain sub-tuples (i.e., nesting), such as ©[ [ 14, 21 ], 9 ]©, which is a 2-element tuple whose first element is itself a tuple.
     909Tuples are permitted to contain sub-tuples (i.e., nesting), such as \lstinline@[ [ 14, 21 ], 9 ]@, which is a 2-element tuple whose first element is itself a tuple.
    901910Note, a tuple is not a record (structure);
    902911a record denotes a single value with substructure, whereas a tuple is multiple values with no substructure (see flattening coercion in Section 12.1).
     
    908917The general syntax of a tuple type is:
    909918\begin{lstlisting}
    910 [ §\emph{typelist}§ ]
    911 \end{lstlisting}
    912 where ©$\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.
     919[ @\emph{typelist}@ ]
     920\end{lstlisting}
     921where \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.
    913922Examples of tuple types include:
    914923\begin{lstlisting}
     
    918927[ * [ 5 ] int, * * char, * [ [ int, int ] ] (int, int) ]
    919928\end{lstlisting}
    920 Like tuples, tuple types may be nested, such as ©[ [ int, int ], int ]©, which is a 2-element tuple type whose first element is itself a tuple type.
     929Like tuples, tuple types may be nested, such as \lstinline@[ [ int, int ], int ]@, which is a 2-element tuple type whose first element is itself a tuple type.
    921930
    922931Examples of declarations using tuple types are:
     
    954963tuple does not have structure like a record; a tuple is simply converted into a list of components.
    955964\begin{rationale}
    956 The present implementation of \CFA does not support nested routine calls when the inner routine returns multiple values; i.e., a statement such as ©g( f() )© is not supported.
     965The present implementation of \CFA does not support nested routine calls when the inner routine returns multiple values; i.e., a statement such as \lstinline@g( f() )@ is not supported.
    957966Using a temporary variable to store the  results of the inner routine and then passing this variable to the outer routine works, however.
    958967\end{rationale}
     
    983992\begin{rationale}
    984993Unfortunately, C's syntax for subscripts precluded treating them as tuples.
    985 The C subscript list has the form ©[i][j]...© and not ©[i, j, ...]©.
    986 Therefore, there is no syntactic way for a routine returning multiple values to specify the different subscript values, e.g., ©f[g()]© always means a single subscript value because there is only one set of brackets.
    987 Fixing this requires a major change to C because the syntactic form ©M[i, j, k]© already has a particular meaning: ©i, j, k© is a comma expression.
     994The C subscript list has the form \lstinline@[i][j]...@ and not \lstinline@i, j, ...]@.
     995Therefore, there is no syntactic way for a routine returning multiple values to specify the different subscript values, e.g., \lstinline@f[g()]@ always means a single subscript value because there is only one set of brackets.
     996Fixing this requires a major change to C because the syntactic form \lstinline@M[i, j, k]@ already has a particular meaning: \lstinline@i, j, k@ is a comma expression.
    988997\end{rationale}
    989998
     
    10041013[ a, b, c, d ] = w
    10051014\end{lstlisting}
    1006 ©w© is implicitly opened to yield a tuple of four values, which are then assigned individually.
     1015\lstinline@w@ is implicitly opened to yield a tuple of four values, which are then assigned individually.
    10071016
    10081017A \newterm{flattening coercion} coerces a nested tuple, i.e., a tuple with one or more components, which are themselves tuples, into a flattened tuple, which is a tuple whose components are not tuples, as in:
     
    10121021First the right-hand tuple is flattened and then the values are assigned individually.
    10131022Flattening is also performed on tuple types.
    1014 For example, the type ©[ int, [ int, int ], int ]© can be coerced, using flattening, into the type ©[ int, int, int, int ]©.
     1023For example, the type \lstinline@[ int, [ int, int ], int ]@ can be coerced, using flattening, into the type \lstinline@[ int, int, int, int ]@.
    10151024
    10161025A \newterm{structuring coercion} is the opposite of flattening;
    10171026a tuple is structured into a more complex nested tuple.
    1018 For example, structuring the tuple ©[ 1, 2, 3, 4 ]© into the tuple ©[ 1, [ 2, 3 ], 4 ]© or the tuple type ©[ int, int, int, int ]© into the tuple type ©[ int, [ int, int ], int ]©.
     1027For example, structuring the tuple \lstinline@[ 1, 2, 3, 4 ]@ into the tuple \lstinline@[ 1, [ 2, 3 ], 4 ]@ or the tuple type \lstinline@[ int, int, int, int ]@ into the tuple type \lstinline@[ int, [ int, int ], int ]@.
    10191028In the following example, the last assignment illustrates all the tuple coercions:
    10201029\begin{lstlisting}
     
    10241033\end{lstlisting}
    10251034Starting on the right-hand tuple in the last assignment statement, w is opened, producing a tuple of four values;
    1026 therefore, the right-hand tuple is now the tuple ©[ [ 1, 2, 3, 4 ], 5 ]©.
    1027 This tuple is then flattened, yielding ©[ 1, 2, 3, 4, 5 ]©, which is structured into ©[ 1, [ 2, 3, 4, 5 ] ]© to match the tuple type of the left-hand side.
    1028 The tuple ©[ 2, 3, 4, 5 ]© is then closed to create a tuple value.
    1029 Finally, ©x© is assigned ©1© and ©w© is assigned the tuple value using multiple assignment (see Section 14).
     1035therefore, the right-hand tuple is now the tuple \lstinline@[ [ 1, 2, 3, 4 ], 5 ]@.
     1036This tuple is then flattened, yielding \lstinline@[ 1, 2, 3, 4, 5 ]@, which is structured into \lstinline@[ 1, [ 2, 3, 4, 5 ] ]@ to match the tuple type of the left-hand side.
     1037The tuple \lstinline@[ 2, 3, 4, 5 ]@ is then closed to create a tuple value.
     1038Finally, \lstinline@x@ is assigned \lstinline@1@ and \lstinline@w@ is assigned the tuple value using multiple assignment (see Section 14).
    10301039\begin{rationale}
    10311040A possible additional language extension is to use the structuring coercion for tuples to initialize a complex record with a tuple.
     
    10381047Mass assignment has the following form:
    10391048\begin{lstlisting}
    1040 [ §\emph{lvalue}§, ..., §\emph{lvalue}§ ] = §\emph{expr}§;
    1041 \end{lstlisting}
    1042 The left-hand 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 left-hand side of a conventional assignment statement.
    1043 ©$\emph{expr}$© is any standard arithmetic expression.
     1049[ @\emph{lvalue}@, ..., @\emph{lvalue}@ ] = @\emph{expr}@;
     1050\end{lstlisting}
     1051The left-hand 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 left-hand side of a conventional assignment statement.
     1052\lstinline@$\emph{expr}$@ is any standard arithmetic expression.
    10441053Clearly, the types of the entities being assigned must be type compatible with the value of the expression.
    10451054
     
    10671076*a1 = t; *a2 = t; *a3 = t;
    10681077\end{lstlisting}
    1069 The temporary ©t© is necessary to store the value of the expression to eliminate conversion issues.
     1078The temporary \lstinline@t@ is necessary to store the value of the expression to eliminate conversion issues.
    10701079The temporaries for the addresses are needed so that locations on the left-hand side do not change as the values are assigned.
    1071 In this case, ©y[i]© uses the previous value of ©i© and not the new value set at the beginning of the mass assignment.
     1080In this case, \lstinline@y[i]@ uses the previous value of \lstinline@i@ and not the new value set at the beginning of the mass assignment.
    10721081
    10731082
     
    10771086Multiple assignment has the following form:
    10781087\begin{lstlisting}
    1079 [ §\emph{lvalue}§, . . ., §\emph{lvalue}§ ] = [ §\emph{expr}§, . . ., §\emph{expr}§ ];
    1080 \end{lstlisting}
    1081 The left-hand side is a tuple of \emph{lvalues}, and the right-hand side is a tuple of \emph{expr}s.
    1082 Each \emph{expr} appearing on the righthand side of a multiple assignment statement is assigned to the corresponding \emph{lvalues} on the left-hand side of the statement using parallel semantics for each assignment.
     1088[ @\emph{lvalue}@, . . ., @\emph{lvalue}@ ] = [ @\emph{expr}@, . . ., @\emph{expr}@ ];
     1089\end{lstlisting}
     1090The left-hand side is a tuple of \lstinline@$\emph{lvalues}$@, and the right-hand side is a tuple of \lstinline@$\emph{expr}$@s.
     1091Each \lstinline@$\emph{expr}$@ appearing on the righthand side of a multiple assignment statement is assigned to the corresponding \lstinline@$\emph{lvalues}$@ on the left-hand side of the statement using parallel semantics for each assignment.
    10831092An example of multiple assignment is:
    10841093\begin{lstlisting}
    10851094[ x, y, z ] = [ 1, 2, 3 ];
    10861095\end{lstlisting}
    1087 Here, the values ©1©, ©2© and ©3© are assigned, respectively, to the variables ©x©, ©y© and ©z©.
     1096Here, the values \lstinline@1@, \lstinline@2@ and \lstinline@3@ are assigned, respectively, to the variables \lstinline@x@, \lstinline@y@ and \lstinline@z@.
    10881097 A more complex example is:
    10891098\begin{lstlisting}
    10901099[ i, y[ i ], z ] = [ 1, i, a + b ];
    10911100\end{lstlisting}
    1092 Here, the values ©1©, ©i© and ©a + b© are assigned to the variables ©i©, ©y[i]© and ©z©, respectively.
     1101Here, the values \lstinline@1@, \lstinline@i@ and \lstinline@a + b@ are assigned to the variables \lstinline@i@, \lstinline@y[i]@ and \lstinline@z@, respectively.
    10931102 Note, the parallel semantics of
    10941103multiple assignment ensures:
     
    10961105[ x, y ] = [ y, x ];
    10971106\end{lstlisting}
    1098 correctly interchanges (swaps) the values stored in ©x© and ©y©.
     1107correctly interchanges (swaps) the values stored in \lstinline@x@ and \lstinline@y@.
    10991108The following cases are errors:
    11001109\begin{lstlisting}
     
    11171126Cascade assignment has the following form:
    11181127\begin{lstlisting}
    1119 §\emph{tuple}§ = §\emph{tuple}§ = ... = §\emph{tuple}§;
     1128@\emph{tuple}@ = @\emph{tuple}@ = ... = @\emph{tuple}@;
    11201129\end{lstlisting}
    11211130and it has the same parallel semantics as for mass and multiple assignment.
     
    11351144Its general form is:
    11361145\begin{lstlisting}
    1137 §\emph{expr}§ . [ §\emph{fieldlist}§ ]
    1138 §\emph{expr}§ -> [ §\emph{fieldlist}§ ]
    1139 \end{lstlisting}
    1140 \emph{expr} is any expression yielding a value of type record, e.g., ©struct©, ©union©.
    1141 Each element of \emph{ fieldlist} is an element of the record specified by \emph{expr}.
     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@.
     1150Each element of \lstinline@$\emph{ fieldlist}$@ is an element of the record specified by \lstinline@$\emph{expr}$@.
    11421151A record-field tuple may be used anywhere a tuple can be used. An example of the use of a record-field tuple is
    11431152the following:
     
    11541163also, it is unnecessary to specify all the fields of a struct in a multiple record-field tuple.
    11551164
    1156 If a field of a ©struct© is itself another ©struct©, multiple fields of this subrecord can be specified using a nested record-field tuple, as in the following example:
     1165If a field of a \lstinline@struct@ is itself another \lstinline@struct@, multiple fields of this subrecord can be specified using a nested record-field tuple, as in the following example:
    11571166\begin{lstlisting}
    11581167struct inner {
     
    11711180\section{Labelled Break/Continue}
    11721181
    1173 While C provides ©break© and ©continue© statements for altering control flow, both are restricted to one level of nesting for a particular control structure.
    1174 Unfortunately, this restriction forces programmers to use ©goto© to achieve the equivalent for more than one level of nesting.
    1175 To prevent having to make this switch, the ©break© and ©continue© are extended with a target label to support static multi-level exit~\cite{Buhr85,Java}.
    1176 For the labelled ©break©, it is possible to specify which control structure is the target for exit, as in:
     1182While C provides \lstinline@break@ and \lstinline@continue@ statements for altering control flow, both are restricted to one level of nesting for a particular control structure.
     1183Unfortunately, this restriction forces programmers to use \lstinline@goto@ to achieve the equivalent for more than one level of nesting.
     1184To prevent having to make this switch, the \lstinline@break@ and \lstinline@continue@ are extended with a target label to support static multi-level exit~\cite{Buhr85,Java}.
     1185For the labelled \lstinline@break@, it is possible to specify which control structure is the target for exit, as in:
    11771186\begin{quote2}
    11781187\begin{tabular}{@{}l@{\hspace{30pt}}l@{}}
    11791188\multicolumn{1}{c@{\hspace{30pt}}}{\textbf{\CFA}}       & \multicolumn{1}{c}{\textbf{C}}        \\
    11801189\begin{lstlisting}
    1181 ®L1:® for ( ... ) {
    1182         ®L2:® for ( ... ) {
    1183                 ®L3:® for ( ... ) {
    1184                         ... break ®L1®; ...
    1185                         ... break ®L2®; ...
    1186                         ... break ®L3®; // or break
     1190`L1:` for ( ... ) {
     1191        `L2:` for ( ... ) {
     1192                `L3:` for ( ... ) {
     1193                        ... break `L1`; ...
     1194                        ... break `L2`; ...
     1195                        ... break `L3`; // or break
    11871196                }
    11881197        }
     
    12041213\end{quote2}
    12051214The inner most loop has three exit points, which cause termination of one or more of the three nested loops, respectively.
    1206 For the labelled ©continue©, it is possible to specify which control structure is the target for the next loop iteration, as in:
     1215For the labelled \lstinline@continue@, it is possible to specify which control structure is the target for the next loop iteration, as in:
    12071216\begin{quote2}
    12081217\begin{tabular}{@{}l@{\hspace{30pt}}l@{}}
    12091218\multicolumn{1}{c@{\hspace{30pt}}}{\textbf{\CFA}}       & \multicolumn{1}{c}{\textbf{C}}        \\
    12101219\begin{lstlisting}
    1211 ®L1®: for ( ... ) {
    1212         ®L2®: for ( ... ) {
    1213                 ®L3®: for ( ... ) {
    1214                         ... continue ®L1®; ...
    1215                         ... continue ®L2®; ...
    1216                         ... continue ®L3®; ...
     1220`L1`: for ( ... ) {
     1221        `L2`: for ( ... ) {
     1222                `L3`: for ( ... ) {
     1223                        ... continue `L1`; ...
     1224                        ... continue `L2`; ...
     1225                        ... continue `L3`; ...
    12171226
    12181227                }
     
    12401249\end{quote2}
    12411250The inner most loop has three restart points, which cause the next loop iteration to begin, respectively.
    1242 For both ©break© and ©continue©, the target label must be directly associated with a ©for©, ©while© or ©do© statement;
    1243 for ©break©, the target label can also be associated with a ©switch© statement.
    1244 Both ©break© and ©continue© with target labels are simply a ©goto© restricted in the following ways:
     1251For both \lstinline@break@ and \lstinline@continue@, the target label must be directly associated with a \lstinline@for@, \lstinline@while@ or \lstinline@do@ statement;
     1252for \lstinline@break@, the target label can also be associated with a \lstinline@switch@ statement.
     1253Both \lstinline@break@ and \lstinline@continue@ with target labels are simply a \lstinline@goto@ restricted in the following ways:
    12451254\begin{itemize}
    12461255\item
     
    12511260Since they always transfers out of containing control structures, they cannot be used to branch into a control structure.
    12521261\end{itemize}
    1253 The advantage of the labelled ©break©/©continue© is that it allows static multi-level exits without having to use the ©goto© statement and ties control flow to the target control structure rather than an arbitrary point in a program.
     1262The advantage of the labelled \lstinline@break@/\lstinline@continue@ is that it allows static multi-level exits without having to use the \lstinline@goto@ statement and ties control flow to the target control structure rather than an arbitrary point in a program.
    12541263Furthermore, the location of the label at the beginning of the target control structure informs the reader that complex control-flow is occurring in the body of the control structure.
    1255 With ©goto©, the label at the end of the control structure fails to convey this important clue early enough to the reader.
     1264With \lstinline@goto@, the label at the end of the control structure fails to convey this important clue early enough to the reader.
    12561265Finally, using an explicit target for the transfer instead of an implicit target allows new nested loop or switch constructs to be added or removed without affecting other constructs.
    1257 The implicit targets of the current ©break© and ©continue©, i.e., the closest enclosing loop or ©switch©, change as certain constructs are added or removed.
     1266The implicit targets of the current \lstinline@break@ and \lstinline@continue@, i.e., the closest enclosing loop or \lstinline@switch@, change as certain constructs are added or removed.
    12581267
    12591268
    12601269\section{Switch Statement}
    12611270
    1262 C allows a number of questionable forms for the ©switch© statement:
     1271C allows a number of questionable forms for the \lstinline@switch@ statement:
    12631272\begin{enumerate}
    12641273\item
    1265 By default, the end of a ©case© clause\footnote{
    1266 In this section, the term \emph{case clause} refers to either a ©case© or ©default© clause.}
    1267 \emph{falls through} to the next ©case© clause in the ©switch© statement;
    1268 to exit a ©switch© statement from a ©case© clause requires explicitly terminating the clause with a transfer statement, most commonly ©break©, as in:
     1274By default, the end of a \lstinline@case@ clause\footnote{
     1275In this section, the term \emph{case clause} refers to either a \lstinline@case@ or \lstinline@default@ clause.}
     1276\emph{falls through} to the next \lstinline@case@ clause in the \lstinline@switch@ statement;
     1277to exit a \lstinline@switch@ statement from a \lstinline@case@ clause requires explicitly terminating the clause with a transfer statement, most commonly \lstinline@break@, as in:
    12691278\begin{lstlisting}
    12701279switch ( i ) {
     
    12911300\end{lstlisting}
    12921301In this example, case 2 is always done if case 3 is done.
    1293 This control flow is difficult to simulate with if statements or a ©switch© statement without fall-through as code must be duplicated or placed in a separate routine.
     1302This control flow is difficult to simulate with if statements or a \lstinline@switch@ statement without fall-through as code must be duplicated or placed in a separate routine.
    12941303C also uses fall-through to handle multiple case-values resulting in the same action, as in:
    12951304\begin{lstlisting}
     
    13041313\end{lstlisting}
    13051314However, this situation is handled in other languages without fall-through by allowing a list of case values.
    1306 While fall-through itself is not a problem, the problem occurs when fall-through is the ©default©, as this semantics is not intuitive to most programmers and is different from virtually all other programming languages with a ©switch© statement.
    1307 Hence, ©default© fall-through semantics results in a large number of programming errors as programmers often forget the ©break© statement at the end of a ©case© clause, resulting in inadvertent fall-through.
    1308 
    1309 \item
    1310 It is possible to place ©case© clauses on statements nested \emph{within} the body of the ©switch© statement, as in:
     1315While fall-through itself is not a problem, the problem occurs when fall-through is the \lstinline@default@, as this semantics is not intuitive to most programmers and is different from virtually all other programming languages with a \lstinline@switch@ statement.
     1316Hence, \lstinline@default@ fall-through semantics results in a large number of programming errors as programmers often forget the \lstinline@break@ statement at the end of a \lstinline@case@ clause, resulting in inadvertent fall-through.
     1317
     1318\item
     1319It is possible to place \lstinline@case@ clauses on statements nested \emph{within} the body of the \lstinline@switch@ statement, as in:
    13111320\begin{lstlisting}
    13121321switch ( i ) {
     
    13491358}
    13501359\end{lstlisting}
    1351 which unrolls a loop N times (N = 8 above) and uses the ©switch© statement to deal with any iterations not a multiple of N.
     1360which unrolls a loop N times (N = 8 above) and uses the \lstinline@switch@ statement to deal with any iterations not a multiple of N.
    13521361While efficient, this sort of special purpose usage is questionable:
    13531362\begin{quote}
     
    13561365\end{quote}
    13571366\item
    1358 It is possible to place the ©default© clause anywhere in the list of labelled clauses for a ©switch© statement, rather than only at the end.
    1359 Virtually all programming languages with a ©switch© statement require the ©default© clause to appear last in the case-clause list.
    1360 The logic for this semantics is that after checking all the ©case© clauses without success, the ©default© clause is selected;
    1361 hence, physically placing the ©default© clause at the end of the ©case© clause list matches with this semantics.
    1362 This physical placement can be compared to the physical placement of an ©else© clause at the end of a series of connected ©if©/©else© statements.
    1363 
    1364 \item
    1365 It is possible to place unreachable code at the start of a ©switch© statement, as in:
     1367It is possible to place the \lstinline@default@ clause anywhere in the list of labelled clauses for a \lstinline@switch@ statement, rather than only at the end.
     1368Virtually all programming languages with a \lstinline@switch@ statement require the \lstinline@default@ clause to appear last in the case-clause list.
     1369The logic for this semantics is that after checking all the \lstinline@case@ clauses without success, the \lstinline@default@ clause is selected;
     1370hence, physically placing the \lstinline@default@ clause at the end of the \lstinline@case@ clause list matches with this semantics.
     1371This physical placement can be compared to the physical placement of an \lstinline@else@ clause at the end of a series of connected \lstinline@if@/\lstinline@else@ statements.
     1372
     1373\item
     1374It is possible to place unreachable code at the start of a \lstinline@switch@ statement, as in:
    13661375\begin{lstlisting}
    13671376switch ( x ) {
     
    13731382}
    13741383\end{lstlisting}
    1375 While the declaration of the local variable ©y© is useful and its scope is across all ©case© clauses, the initialization for such a variable is defined to never be executed because control always transfers over it.
    1376 Furthermore, any statements before the first ©case© clause can only be executed if labelled and transfered to using a ©goto©, either from outside or inside of the ©switch©.
     1384While the declaration of the local variable \lstinline@y@ is useful and its scope is across all \lstinline@case@ clauses, the initialization for such a variable is defined to never be executed because control always transfers over it.
     1385Furthermore, any statements before the first \lstinline@case@ clause can only be executed if labelled and transfered to using a \lstinline@goto@, either from outside or inside of the \lstinline@switch@.
    13771386As mentioned, transfer into control structures should be forbidden.
    1378 Transfers from within the ©switch© body using a ©goto© are equally unpalatable.
     1387Transfers from within the \lstinline@switch@ body using a \lstinline@goto@ are equally unpalatable.
    13791388\end{enumerate}
    13801389Before discussing potential language changes to deal with these problems, it is worth observing that in a typical C program:
    13811390\begin{itemize}
    13821391\item
    1383 the number of ©switch© statements is small,
    1384 \item
    1385 most ©switch© statements are well formed (i.e., no Duff's device),
    1386 \item
    1387 the ©default© clause is usually written as the last case-clause,
    1388 \item
    1389 and there is only a medium amount of fall-through from one ©case© clause to the next, and most of these result from a list of case values executing common code, rather than a sequence of case actions that compound.
     1392the number of \lstinline@switch@ statements is small,
     1393\item
     1394most \lstinline@switch@ statements are well formed (i.e., no Duff's device),
     1395\item
     1396the \lstinline@default@ clause is usually written as the last case-clause,
     1397\item
     1398and there is only a medium amount of fall-through from one \lstinline@case@ clause to the next, and most of these result from a list of case values executing common code, rather than a sequence of case actions that compound.
    13901399\end{itemize}
    13911400These observations should help to put the effects of suggested changes into perspective.
     
    13931402\begin{enumerate}
    13941403\item
    1395 Eliminating the ©default© fall-through problem has the greatest potential for affecting existing code.
    1396 However, even if fall-through is removed, most ©switch© statements would continue to work because of the explicit transfers already present at the end of each ©case© clause, and the common placement of the ©default© clause at the end of the case list.
    1397 In addition, the above grammar provides for the most common use of fall-through, i.e., a list of ©case© clauses executing common code, e.g.:
     1404Eliminating the \lstinline@default@ fall-through problem has the greatest potential for affecting existing code.
     1405However, even if fall-through is removed, most \lstinline@switch@ statements would continue to work because of the explicit transfers already present at the end of each \lstinline@case@ clause, and the common placement of the \lstinline@default@ clause at the end of the case list.
     1406In addition, the above grammar provides for the most common use of fall-through, i.e., a list of \lstinline@case@ clauses executing common code, e.g.:
    13981407\begin{lstlisting}
    13991408case 1:  case 2:  case 3: ...
    14001409\end{lstlisting}
    14011410Nevertheless, reversing the default action would have a non-trivial effect on case actions that compound, such as the above example of processing shell arguments.
    1402 Therefore, to preserve backwards compatibility, it is necessary to introduce a new kind of ©switch© statement, called ©choose©, with no fall-through semantics.
    1403 The ©choose© statement is identical to the new ©switch© statement, except there is no implicit fall-through between case-clauses and the ©break© statement applies to the enclosing loop construct (as for the continue statement in a ©switch© statement).
     1411Therefore, to preserve backwards compatibility, it is necessary to introduce a new kind of \lstinline@switch@ statement, called \lstinline@choose@, with no fall-through semantics.
     1412The \lstinline@choose@ statement is identical to the new \lstinline@switch@ statement, except there is no implicit fall-through between case-clauses and the \lstinline@break@ statement applies to the enclosing loop construct (as for the continue statement in a \lstinline@switch@ statement).
    14041413It is still possible to fall-through if a case-clause ends with the new keyword fallthru, e.g.:
    14051414\begin{lstlisting}
     
    14171426\item
    14181427Eliminating Duff's device is straightforward and only invalidates a small amount of very questionable code.
    1419 The solution is to allow ©case© clauses to only appear at the same nesting level as the ©switch© body, as is done in most other programming languages with ©switch© statements.
    1420 \item
    1421 The issue of ©default© at locations other than at the end of the cause clause can be solved by using good programming style, and there are a few reasonable situations involving fall-through where the ©default© clause may appear is locations other than at the end.
     1428The solution is to allow \lstinline@case@ clauses to only appear at the same nesting level as the \lstinline@switch@ body, as is done in most other programming languages with \lstinline@switch@ statements.
     1429\item
     1430The issue of \lstinline@default@ at locations other than at the end of the cause clause can be solved by using good programming style, and there are a few reasonable situations involving fall-through where the \lstinline@default@ clause may appear is locations other than at the end.
    14221431Therefore, no language change is made for this issue.
    14231432\item
    1424 Dealing with unreachable code at the start of a ©switch© statement is solved by defining the declaration-list, including any associated initialization, at the start of a ©switch© statement body to be executed before the transfer to the appropriate ©case© clause.
     1433Dealing with unreachable code at the start of a \lstinline@switch@ statement is solved by defining the declaration-list, including any associated initialization, at the start of a \lstinline@switch@ statement body to be executed before the transfer to the appropriate \lstinline@case@ clause.
    14251434This semantics is the same as for declarations at the start of a loop body, which are executed before each iteration of the loop body.
    1426 As well, this grammar does not allow statements to appear before the first ©case© clause.
     1435As well, this grammar does not allow statements to appear before the first \lstinline@case@ clause.
    14271436The change is compatible for declarations with initialization in this context because existing code cannot assume the initialization has occurred.
    14281437The change is incompatible for statements, but any existing code using it is highly questionable, as in:
     
    14341443}
    14351444\end{lstlisting}
    1436 The statement after the ©switch© can never be executed unless it is labelled.
    1437 If it is labelled, it must be transfered to from outside or inside the ©switch© statement, neither of which is acceptable control flow.
     1445The statement after the \lstinline@switch@ can never be executed unless it is labelled.
     1446If it is labelled, it must be transfered to from outside or inside the \lstinline@switch@ statement, neither of which is acceptable control flow.
    14381447\end{enumerate}
    14391448
     
    14411450\section{Case Clause}
    14421451
    1443 C restricts the ©case© clause of a ©switch© statement to a single value.
    1444 For multiple ©case© clauses associated with the same statement, it is necessary to have multiple ©case© clauses rather than multiple values.
    1445 Requiring a ©case© clause for each value does not seem to be in the spirit of brevity normally associated with C.
    1446 Therefore, the ©case© clause is extended with a list of values, as in:
     1452C restricts the \lstinline@case@ clause of a \lstinline@switch@ statement to a single value.
     1453For multiple \lstinline@case@ clauses associated with the same statement, it is necessary to have multiple \lstinline@case@ clauses rather than multiple values.
     1454Requiring a \lstinline@case@ clause for each value does not seem to be in the spirit of brevity normally associated with C.
     1455Therefore, the \lstinline@case@ clause is extended with a list of values, as in:
    14471456\begin{quote2}
    14481457\begin{tabular}{@{}l@{\hspace{30pt}}l@{\hspace{20pt}}l@{}}
     
    14501459\begin{lstlisting}
    14511460switch ( i ) {
    1452   ®case 1, 3, 5®:
     1461  `case 1, 3, 5`:
    14531462        ...
    1454   ®case 2, 4, 6®:
     1463  `case 2, 4, 6`:
    14551464        ...
    14561465}
     
    14821491\begin{lstlisting}
    14831492switch ( i ) {
    1484   ®case 1~5:®
     1493  `case 1~5:`
    14851494        ...
    1486   ®case 10~15:®
     1495  `case 10~15:`
    14871496        ...
    14881497}
     
    17391748
    17401749The syntax for using references in \CFA is the same as \CC with the exception of reference initialization.
    1741 Use ©&© to specify a reference, and access references just like regular objects, not like pointers (use dot notation to access fields).
     1750Use \lstinline@&@ to specify a reference, and access references just like regular objects, not like pointers (use dot notation to access fields).
    17421751When initializing a reference, \CFA uses a different syntax which differentiates reference initialization from assignment to a reference.
    1743 The ©&© is used on both sides of the expression to clarify that the address of the reference is being set to the address of the variable to which it refers.
     1752The \lstinline@&@ is used on both sides of the expression to clarify that the address of the reference is being set to the address of the variable to which it refers.
    17441753
    17451754\begin{figure}
     
    18141823In \CFA, as in C, all scalar types can be incremented and
    18151824decremented, which is defined in terms of adding or subtracting 1.
    1816 The operations ©&&©, ©||©, and ©!© can be applied to any scalar arguments and are defined in terms of comparison against 0 (ex. ©(a && b)© becomes ©(a != 0 && b != 0)©).
     1825The operations \lstinline@&&@, \lstinline@||@, and \lstinline@!@ can be applied to any scalar arguments and are defined in terms of comparison against 0 (ex. \lstinline@(a && b)@ becomes \lstinline@(a != 0 && b != 0)@).
    18171826
    18181827In C, the integer constants 0 and 1 suffice because the integer promotion rules can convert them to any
     
    18231832polymorphic parameters, and user-defined pointer-like types may need a null value.
    18241833Defining special
    1825 constants for a user-defined type is more efficient than defining a conversion to the type from ©_Bool©.
     1834constants for a user-defined type is more efficient than defining a conversion to the type from \lstinline@_Bool@.
    18261835
    18271836Why just 0 and 1? Why not other integers? No other integers have special status in C.
     
    19061915\begin{tabular}[t]{ll}
    19071916%identifier & operation \\ \hline
    1908 ©?[?]© & subscripting \impl{?[?]}\\
    1909 ©?()© & function call \impl{?()}\\
    1910 ©?++© & postfix increment \impl{?++}\\
    1911 ©?--© & postfix decrement \impl{?--}\\
    1912 ©++?© & prefix increment \impl{++?}\\
    1913 ©--?© & prefix decrement \impl{--?}\\
    1914 ©*?© & dereference \impl{*?}\\
    1915 ©+?© & unary plus \impl{+?}\\
    1916 ©-?© & arithmetic negation \impl{-?}\\
    1917 ©~?© & bitwise negation \impl{~?}\\
    1918 ©!?© & logical complement \impl{"!?}\\
    1919 ©?*?© & multiplication \impl{?*?}\\
    1920 ©?/?© & division \impl{?/?}\\
     1917\lstinline@?[?]@ & subscripting \impl{?[?]}\\
     1918\lstinline@?()@ & function call \impl{?()}\\
     1919\lstinline@?++@ & postfix increment \impl{?++}\\
     1920\lstinline@?--@ & postfix decrement \impl{?--}\\
     1921\lstinline@++?@ & prefix increment \impl{++?}\\
     1922\lstinline@--?@ & prefix decrement \impl{--?}\\
     1923\lstinline@*?@ & dereference \impl{*?}\\
     1924\lstinline@+?@ & unary plus \impl{+?}\\
     1925\lstinline@-?@ & arithmetic negation \impl{-?}\\
     1926\lstinline@~?@ & bitwise negation \impl{~?}\\
     1927\lstinline@!?@ & logical complement \impl{"!?}\\
     1928\lstinline@?*?@ & multiplication \impl{?*?}\\
     1929\lstinline@?/?@ & division \impl{?/?}\\
    19211930\end{tabular}\hfil
    19221931\begin{tabular}[t]{ll}
    19231932%identifier & operation \\ \hline
    1924 ©?%?© & remainder \impl{?%?}\\
    1925 ©?+?© & addition \impl{?+?}\\
    1926 ©?-?© & subtraction \impl{?-?}\\
    1927 ©?<<?© & left shift \impl{?<<?}\\
    1928 ©?>>?© & right shift \impl{?>>?}\\
    1929 ©?<?© & less than \impl{?<?}\\
    1930 ©?<=?© & less than or equal \impl{?<=?}\\
    1931 ©?>=?© & greater than or equal \impl{?>=?}\\
    1932 ©?>?© & greater than \impl{?>?}\\
    1933 ©?==?© & equality \impl{?==?}\\
    1934 ©?!=?© & inequality \impl{?"!=?}\\
    1935 ©?&?© & bitwise AND \impl{?&?}\\
     1933\lstinline@?%?@ & remainder \impl{?%?}\\
     1934\lstinline@?+?@ & addition \impl{?+?}\\
     1935\lstinline@?-?@ & subtraction \impl{?-?}\\
     1936\lstinline@?<<?@ & left shift \impl{?<<?}\\
     1937\lstinline@?>>?@ & right shift \impl{?>>?}\\
     1938\lstinline@?<?@ & less than \impl{?<?}\\
     1939\lstinline@?<=?@ & less than or equal \impl{?<=?}\\
     1940\lstinline@?>=?@ & greater than or equal \impl{?>=?}\\
     1941\lstinline@?>?@ & greater than \impl{?>?}\\
     1942\lstinline@?==?@ & equality \impl{?==?}\\
     1943\lstinline@?!=?@ & inequality \impl{?"!=?}\\
     1944\lstinline@?&?@ & bitwise AND \impl{?&?}\\
    19361945\end{tabular}\hfil
    19371946\begin{tabular}[t]{ll}
    19381947%identifier & operation \\ \hline
    1939 ©?^?© & exclusive OR \impl{?^?}\\
    1940 ©?|?© & inclusive OR \impl{?"|?}\\
    1941 ©?=?© & simple assignment \impl{?=?}\\
    1942 ©?*=?© & multiplication assignment \impl{?*=?}\\
    1943 ©?/=?© & division assignment \impl{?/=?}\\
    1944 ©?%=?© & remainder assignment \impl{?%=?}\\
    1945 ©?+=?© & addition assignment \impl{?+=?}\\
    1946 ©?-=?© & subtraction assignment \impl{?-=?}\\
    1947 ©?<<=?© & left-shift assignment \impl{?<<=?}\\
    1948 ©?>>=?© & right-shift assignment \impl{?>>=?}\\
    1949 ©?&=?© & bitwise AND assignment \impl{?&=?}\\
    1950 ©?^=?© & exclusive OR assignment \impl{?^=?}\\
    1951 ©?|=?© & inclusive OR assignment \impl{?"|=?}\\
     1948\lstinline@?^?@ & exclusive OR \impl{?^?}\\
     1949\lstinline@?|?@ & inclusive OR \impl{?"|?}\\
     1950\lstinline@?=?@ & simple assignment \impl{?=?}\\
     1951\lstinline@?*=?@ & multiplication assignment \impl{?*=?}\\
     1952\lstinline@?/=?@ & division assignment \impl{?/=?}\\
     1953\lstinline@?%=?@ & remainder assignment \impl{?%=?}\\
     1954\lstinline@?+=?@ & addition assignment \impl{?+=?}\\
     1955\lstinline@?-=?@ & subtraction assignment \impl{?-=?}\\
     1956\lstinline@?<<=?@ & left-shift assignment \impl{?<<=?}\\
     1957\lstinline@?>>=?@ & right-shift assignment \impl{?>>=?}\\
     1958\lstinline@?&=?@ & bitwise AND assignment \impl{?&=?}\\
     1959\lstinline@?^=?@ & exclusive OR assignment \impl{?^=?}\\
     1960\lstinline@?|=?@ & inclusive OR assignment \impl{?"|=?}\\
    19521961\end{tabular}
    19531962\hfil
     
    19581967These identifiers are defined such that the question marks in the name identify the location of the operands.
    19591968These operands represent the parameters to the functions, and define how the operands are mapped to the function call.
    1960 For example, ©a + b© becomes ©?+?(a, b)©.
     1969For example, \lstinline@a + b@ becomes \lstinline@?+?(a, b)@.
    19611970
    19621971In the example below, a new type, myComplex, is defined with an overloaded constructor, + operator, and string operator.
     
    20012010\begin{quote2}
    20022011\begin{tabular}{@{}l@{\hspace{30pt}}ll@{}}
    2003 \multicolumn{1}{c@{\hspace{30pt}}}{\textbf{\CC}}        & \multicolumn{1}{c}{©gcc©}\index{gcc} \\
     2012\multicolumn{1}{c@{\hspace{30pt}}}{\textbf{\CC}}        & \multicolumn{1}{c}{\lstinline@gcc@}\index{gcc} \\
    20042013\begin{lstlisting}
    20052014
     
    20322041\end{itemize}
    20332042
    2034 In \CFA, ©typedef© provides a mechanism to alias long type names with short ones, both globally and locally, but not eliminate the use of the short name.
    2035 ©gcc© provides ©typeof© to declare a secondary variable from a primary variable.
     2043In \CFA, \lstinline@typedef@ provides a mechanism to alias long type names with short ones, both globally and locally, but not eliminate the use of the short name.
     2044\lstinline@gcc@ provides \lstinline@typeof@ to declare a secondary variable from a primary variable.
    20362045\CFA also relies heavily on the specification of the left-hand side of assignment for type inferencing, so in many cases it is crucial to specify the type of the left-hand side to select the correct type of the right-hand expression.
    20372046Only for overloaded routines with the same return type is variable type-inferencing possible.
    2038 Finally, ©auto© presents the programming problem of tracking down a type when the type is actually needed.
     2047Finally, \lstinline@auto@ presents the programming problem of tracking down a type when the type is actually needed.
    20392048For example, given
    20402049\begin{lstlisting}
    2041 auto j = ®...®
    2042 \end{lstlisting}
    2043 and the need to write a routine to compute using ©j©
    2044 \begin{lstlisting}
    2045 void rtn( ®...® parm );
     2050auto j = `...`
     2051\end{lstlisting}
     2052and the need to write a routine to compute using \lstinline@j@
     2053\begin{lstlisting}
     2054void rtn( `...` parm );
    20462055rtn( j );
    20472056\end{lstlisting}
    2048 A programmer must work backwards to determine the type of ©j©'s initialization expression, reconstructing the possibly long generic type-name.
     2057A programmer must work backwards to determine the type of \lstinline@j@'s initialization expression, reconstructing the possibly long generic type-name.
    20492058In this situation, having the type name or a short alias is very useful.
    20502059
     
    20542063At some point, a programmer wants the type of the variable to remain constant and the expression to be in error when it changes.
    20552064
    2056 Given ©typedef© and ©typeof© in \CFA, and the strong need to use the type of left-hand side in inferencing, auto type-inferencing is not supported at this time.
     2065Given \lstinline@typedef@ and \lstinline@typeof@ in \CFA, and the strong need to use the type of left-hand side in inferencing, auto type-inferencing is not supported at this time.
    20572066Should a significant need arise, this feature can be revisited.
    20582067
     
    23562365} s;
    23572366\end{lstlisting}
    2358 The problem occurs in accesing these fields using the selection operation ``©.©'':
     2367The problem occurs in accesing these fields using the selection operation ``\lstinline@.@'':
    23592368\begin{lstlisting}
    23602369s.0 = 0;        // ambiguity with floating constant .0
     
    23632372To make this work, a space is required after the field selection:
    23642373\begin{lstlisting}
    2365 ®s.§\textvisiblespace§0® = 0;
    2366 ®s.§\textvisiblespace§1® = 1;
     2374`s.@\textvisiblespace@0` = 0;
     2375`s.@\textvisiblespace@1` = 1;
    23672376\end{lstlisting}
    23682377While this sytact is awkward, it is unlikely many programers will name fields of a structure 0 or 1.
    2369 Like the \CC lexical problem with closing template-syntax, e.g, ©Foo<Bar<int®>>®©, this issue can be solved with a more powerful lexer/parser.
    2370 
    2371 There are several ambiguous cases with operator identifiers, e.g., ©int *?*?()©, where the string ©*?*?© can be lexed as ©*©/©?*?© or ©*?©/©*?©.
    2372 Since it is common practise to put a unary operator juxtaposed to an identifier, e.g., ©*i©, users will be annoyed if they cannot do this with respect to operator identifiers.
     2378Like the \CC lexical problem with closing template-syntax, e.g, \lstinline@Foo<Bar<int`>>`@, this issue can be solved with a more powerful lexer/parser.
     2379
     2380There are several ambiguous cases with operator identifiers, e.g., \lstinline@int *?*?()@, where the string \lstinline@*?*?@ can be lexed as \lstinline@*@/\lstinline@?*?@ or \lstinline@*?@/\lstinline@*?@.
     2381Since it is common practise to put a unary operator juxtaposed to an identifier, e.g., \lstinline@*i@, users will be annoyed if they cannot do this with respect to operator identifiers.
    23732382Even with this special hack, there are 5 general cases that cannot be handled.
    2374 The first case is for the function-call identifier ©?()©:
    2375 \begin{lstlisting}
    2376 int *§\textvisiblespace§?()();  // declaration: space required after '*'
    2377 *§\textvisiblespace§?()();              // expression: space required after '*'
    2378 \end{lstlisting}
    2379 Without the space, the string ©*?()© is ambiguous without N character look ahead;
    2380 it requires scanning ahead to determine if there is a ©'('©, which is the start of an argument/parameter list.
     2383The first case is for the function-call identifier \lstinline@?()@:
     2384\begin{lstlisting}
     2385int *@\textvisiblespace@?()();  // declaration: space required after '*'
     2386*@\textvisiblespace@?()();              // expression: space required after '*'
     2387\end{lstlisting}
     2388Without the space, the string \lstinline@*?()@ is ambiguous without N character look ahead;
     2389it requires scanning ahead to determine if there is a \lstinline@'('@, which is the start of an argument/parameter list.
    23812390
    23822391The 4 remaining cases occur in expressions:
    23832392\begin{lstlisting}
    2384 i++§\textvisiblespace§?i:0;             // space required before '?'
    2385 i--§\textvisiblespace§?i:0;             // space required before '?'
    2386 i§\textvisiblespace§?++i:0;             // space required after '?'
    2387 i§\textvisiblespace§?--i:0;             // space required after '?'
    2388 \end{lstlisting}
    2389 In the first two cases, the string ©i++?© is ambiguous, where this string can be lexed as ©i© / ©++?© or ©i++© / ©?©;
    2390 it requires scanning ahead to determine if there is a ©'('©, which is the start of an argument list.
    2391 In the second two cases, the string ©?++x© is ambiguous, where this string can be lexed as ©?++© / ©x© or ©?© / y©++x©;
    2392 it requires scanning ahead to determine if there is a ©'('©, which is the start of an argument list.
     2393i++@\textvisiblespace@?i:0;             // space required before '?'
     2394i--@\textvisiblespace@?i:0;             // space required before '?'
     2395i@\textvisiblespace@?++i:0;             // space required after '?'
     2396i@\textvisiblespace@?--i:0;             // space required after '?'
     2397\end{lstlisting}
     2398In the first two cases, the string \lstinline@i++?@ is ambiguous, where this string can be lexed as \lstinline@i@ / \lstinline@++?@ or \lstinline@i++@ / \lstinline@?@;
     2399it requires scanning ahead to determine if there is a \lstinline@'('@, which is the start of an argument list.
     2400In the second two cases, the string \lstinline@?++x@ is ambiguous, where this string can be lexed as \lstinline@?++@ / \lstinline@x@ or \lstinline@?@ / y\lstinline@++x@;
     2401it requires scanning ahead to determine if there is a \lstinline@'('@, which is the start of an argument list.
    23932402
    23942403
     
    33163325
    33173326
    3318 \subsection[Comparing Key Features of CFA]{Comparing Key Features of \CFA}
     3327\subsection{Comparing Key Features of \CFA}
    33193328
    33203329
     
    36903699
    36913700\begin{comment}
    3692 \subsubsection{Modules / Packages}
     3701\subsubsection{Modules/Packages}
    36933702
    36943703\begin{lstlisting}
     
    39323941
    39333942
    3934 \subsubsection[C++]{\CC}
     3943\subsubsection{\CC}
    39353944
    39363945\CC is a general-purpose programming language.
     
    40064015\begin{enumerate}
    40074016\item
    4008 Change type of character literal ©int© to ©char©.
     4017Change type of character literal \lstinline@int@ to \lstinline@char@.
    40094018This change allows overloading differentiation argument type matching, e.g.:
    40104019\begin{lstlisting}
     
    40234032
    40244033\item
    4025 Change: String literals made ©const© \\
    4026 The type of a string literal is changed from ©array of char© to ©array of const char©.
    4027 The type of a wide string literal is changed from ©array of wchar_t© to ©array of const wchar_t©. \\
     4034Change: String literals made \lstinline@const@ \\
     4035The type of a string literal is changed from \lstinline@array of char@ to \lstinline@array of const char@.
     4036The type of a wide string literal is changed from \lstinline@array of wchar_t@ to \lstinline@array of const wchar_t@. \\
    40284037Rationale: This avoids calling an inappropriate overloaded function, which might expect to be able to modify its argument.
    40294038Effect on original feature: Change to semantics of well-defined feature. \\
    4030 Difficulty of converting: Simple syntactic transformation, because string literals can be converted to ©char*;© (4.2).
     4039Difficulty of converting: Simple syntactic transformation, because string literals can be converted to \lstinline@char*;@ (4.2).
    40314040The most common cases are handled by a new but deprecated standard conversion:
    40324041\begin{lstlisting}
     
    40674076
    40684077\CFA is C \emph{incompatible} on this issue, and provides semantics similar to \CC.
    4069 Nested types are not hoisted and can be referenced using the field selection operator ``©.©'', unlike the \CC scope-resolution operator ``©::©''.
     4078Nested types are not hoisted and can be referenced using the field selection operator ``\lstinline@.@'', unlike the \CC scope-resolution operator ``\lstinline@::@''.
    40704079Given 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
    40714081
    40724082\item
     
    40804090struct Y yy; // valid C, invalid C++
    40814091\end{lstlisting}
    4082 Rationale: C++ classes have member functions which require that classes establish scopes.
    4083 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.
    4084 Effect on original feature: Change of semantics of welldefined feature.
    4085 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:
     4092Rationale: C++ classes have member functions which require that classes establish scopes. The C rule
     4093would leave classes as an incomplete scope mechanism which would prevent C++ programmers from maintaining
     4094locality within a class. A coherent set of scope rules for C++ based on the C rule would be very
     4095complicated and C++ programmers would be unable to predict reliably the meanings of nontrivial examples
     4096involving nested or local functions.
     4097Effect on original feature: Change of semantics of welldefined
     4098feature.
     4099Difficulty of converting: Semantic transformation. To make the struct type name visible in the scope of
     4100the enclosing struct, the struct tag could be declared in the scope of the enclosing struct, before the enclosing
     4101struct is defined. Example:
    40864102\begin{lstlisting}
    40874103struct Y; // struct Y and struct X are at the same scope
     
    40904106};
    40914107\end{lstlisting}
    4092 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.
    4093 Note: this is a consequence of the difference in scope rules, which is documented in 3.3.
     4108All the definitions of C struct types enclosed in other struct definitions and accessed outside the scope of
     4109the enclosing struct could be exported to the scope of the enclosing struct. Note: this is a consequence of
     4110the difference in scope rules, which is documented in 3.3.
    40944111How widely used: Seldom.
    40954112\end{enumerate}
     
    41074124\begin{lstlisting}
    41084125int x = 0, y = 1, z = 2;
    4109 ®sout® ®|® x ®|® y ®|® z ®| endl®;
     4126`sout` `|` x `|` y `|` z `| endl`;
    41104127\end{lstlisting}
    41114128&
     
    41164133\end{tabular}
    41174134\end{quote2}
    4118 The \CFA form is half as many characters, and is similar to \Index{Python} I/O with respect to implicit separators.
     4135The \CFA form is half as many characters, and is similar to Python I/O with respect to implicit separators.
    41194136
    41204137The logical-or operator is used because it is the lowest-priority overloadable operator, other than assignment.
     
    41434160A seperator does not appear at the start or end of a line.
    41444161\begin{lstlisting}[belowskip=0pt]
    4145 sout | 1 | 2 | 3 | endl;
     4162sout 1 | 2 | 3 | endl;
    41464163\end{lstlisting}
    41474164\begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    41624179which is a local mechanism to disable insertion of the separator character.
    41634180\item
    4164 A seperator does not appear before a C string starting with the (extended) \Index{ASCII}\index{ASCII!extended} characters: \lstinline[mathescape=off]@([{$£¥¡¿«@
     4181A seperator does not appear before a C string starting with the \Index{extended ASCII}\index{ASCII} characters: \lstinline[mathescape=off]@([{$£¥¿«@
    41654182%$
    41664183\begin{lstlisting}[mathescape=off]
    4167 sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x $" | 4 | "x £" | 5 | "x ¥" | 6 | "x ¡" | 7 | "x ¿" | 8 | "x «" | 9 | endl;
     4184sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x $" | 4 | "x £" | 5 | "x ¥" | 6 | "x ¿" | 7 | "x «" | 8 | endl;
    41684185\end{lstlisting}
    41694186%$
    41704187\begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    4171 x (1 x [2 x {3 x $4 x £5 x ¥6 x ¡7 x ¿8 x «9
     4188x (1 x [2 x {3 x $4 x £5 x ¥6 x ¿7 x «8
    41724189\end{lstlisting}
    41734190%$
    41744191\item
    4175 A seperator does not appear after a C string ending with the (extended) \Index{ASCII}\index{ASCII!extended} characters: ©,.:;!?)]}%¢»©
     4192A seperator does not appear after a C string ending with the extended ASCII characters: \lstinline@,.:;!?)]}%¢»@
    41764193\begin{lstlisting}[belowskip=0pt]
    41774194sout | 1 | ", x" | 2 | ". x" | 3 | ": x" | 4 | "; x" | 5 | "! x" | 6 | "? x" | 7 | ") x" | 8 | "] x" | 9 | "} x"
    4178          | 10 | "% x" | 11 | "¢ x" | 12 | "» x" | endl;
     4195         | 10 | "% x" | 11 | L"¢ x" | 12 | L"» x" | endl;
    41794196\end{lstlisting}
    41804197\begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    41824199\end{lstlisting}
    41834200\item
    4184 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@
     4201A seperator does not appear before or after a C string begining/ending with the characters: \lstinline@\f\n\r\t\v\`'"@
    41854202\begin{lstlisting}[belowskip=0pt]
    4186 sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x" | "x " | 4 | " x" | "x\t" | 1 | "\tx" | endl;
    4187 \end{lstlisting}
    4188 \begin{lstlisting}[mathescape=off,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt]
    4189 x`1`x'2'x"3"x x 4 x x   1       x
     4203sout | "x '" | 1 | "' x \`" | 2 | "\` x \"" | 3 | "\" x" | endl;
     4204\end{lstlisting}
     4205\begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     4206x '1' x \`2\` x "3" x
     4207\end{lstlisting}
     4208\begin{lstlisting}[showtabs=true,aboveskip=0pt]
     4209sout | "x\t" | 1 | "\tx" | endl;
     4210x       1       x
    41904211\end{lstlisting}
    41914212\end{enumerate}
     
    42194240\end{lstlisting}
    42204241\begin{lstlisting}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    4221  1 2 3
     42421 2 3
    42224243\end{lstlisting}
    42234244\begin{lstlisting}[mathescape=off,aboveskip=0pt,aboveskip=0pt,belowskip=0pt]
     
    42304251\end{lstlisting}
    42314252%$
    4232 \begin{comment}
     4253\VRef[Figure]{f:ExampleIO} shows an example of input and output I/O in \CFA.
     4254
     4255\begin{figure}
     4256\begin{lstlisting}[mathescape=off]
    42334257#include <fstream>
    42344258
    42354259int main() {
    4236         int x = 3, y = 5, z = 7;
    4237         sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;
    4238         sout | 1 | 2 | 3 | endl;
    4239         sout | '1' | '2' | '3' | endl;
    4240         sout | 1 | "" | 2 | "" | 3 | endl;
    4241         sout | "x (" | 1 | "x [" | 2 | "x {" | 3 | "x $" | 4 | "x £" | 5 | "x ¥" | 6 | "x ¡" | 7 | "x ¿" | 8 | "x «" | 9 | endl;
    4242         sout | 1 | ", x" | 2 | ". x" | 3 | ": x" | 4 | "; x" | 5 | "! x" | 6 | "? x" | 7 | ") x" | 8 | "] x" | 9 | "} x"
    4243                  | 10 | "% x" | 11 | "¢ x" | 12 | "» x" | endl;
    4244         sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x" | "x " | 4 | " x" | "x\t" | 1 | "\tx" | endl;
    4245         sout | sepOn | 1 | 2 | 3 | sepOn | endl;        // separator at start of line
    4246         sout | 1 | sepOff | 2 | 3 | endl;                       // turn off implicit separator temporarily
    4247         sout | sepDisable | 1 | 2 | 3 | endl;           // turn off implicit separation, affects all subsequent prints
    4248         sout | 1 | sepOn | 2 | 3 | endl;                        // turn on implicit separator temporarily
    4249         sout | sepEnable | 1 | 2 | 3 | endl;            // turn on implicit separation, affects all subsequent prints
    4250         sepSet( sout, ", $" );                                          // change separator from " " to ", $"
    4251         sout | 1 | 2 | 3 | endl;
    4252 
    4253 }
    4254 
    4255 // Local Variables: //
    4256 // tab-width: 4 //
    4257 // End: //
    4258 \end{comment}
    4259 %$
     4260        char c;                                                                                                         // basic types
     4261        short int si;
     4262        unsigned short int usi;
     4263        int i;
     4264        unsigned int ui;
     4265        long int li;
     4266        unsigned long int uli;
     4267        long long int lli;
     4268        unsigned long long int ulli;
     4269        float f;
     4270        double d;
     4271        long double ld;
     4272        float _Complex fc;
     4273        double _Complex dc;
     4274        long double _Complex ldc;
     4275        char s1[10], s2[10];
     4276
     4277        ifstream in;                                                                                            // create / open file
     4278        open( &in, "input.data", "r" );
     4279
     4280        &in | &c                                                                                                        // character
     4281                | &si | &usi | &i | &ui | &li | &uli | &lli | &ulli             // integral
     4282                | &f | &d | &ld                                                                                 // floating point
     4283                | &fc | &dc | &ldc                                                                              // floating-point complex
     4284                | cstr( s1 ) | cstr( s2, 10 );                                                  // C string, length unchecked and checked
     4285
     4286        sout | c | ' ' | endl                                                                           // character
     4287                 | si | usi | i | ui | li | uli | lli | ulli | endl             // integral
     4288                 | f | d | ld | endl                                                                    // floating point
     4289                 | fc | dc | ldc | endl;                                                                // complex
     4290        sout | endl;
     4291        sout | f | "" | d | "" | ld | endl                                                      // floating point without separator
     4292                 | sepDisable | fc | dc | ldc | sepEnable | endl                // complex without separator
     4293                 | sepOn | s1 | sepOff | s2 | endl                                              // local separator removal
     4294                 | s1 | "" | s2 | endl;                                                                 // C string withou separator
     4295        sout | endl;
     4296        sepSet( sout, ", $" );                                                                          // change separator, maximum of 15 characters
     4297        sout | f | d | ld | endl                                                                        // floating point without separator
     4298                 | fc | dc | ldc | endl                                                                 // complex without separator
     4299                 | s1 | s2 | endl;
     4300}
     4301
     4302$ cat input.data
     4303A 1 2 3 4 5 6 7 8 1.1 1.2 1.3 1.1+2.3 1.1-2.3 1.1-2.3 abc xyz
     4304$ a.out
     4305A
     43061 2 3 4 5 6 7 8
     43071.1 1.2 1.3
     43081.1+2.3i 1.1-2.3i 1.1-2.3i
     4309
     43101.11.21.3
     43111.1+2.3i1.1-2.3i1.1-2.3i
     4312 abcxyz
     4313abcxyz
     4314
     43151.1, $1.2, $1.3
     43161.1+2.3i, $1.1-2.3i, $1.1-2.3i
     4317abc, $xyz
     4318\end{lstlisting}
     4319\caption{Example I/O}
     4320\label{f:ExampleIO}
     4321\end{figure}
    42604322
    42614323
     
    42694331
    42704332\begin{lstlisting}
    4271 forall( otype T ) T * malloc( void );§\indexc{malloc}§
     4333forall( otype T ) T * malloc( void );
    42724334forall( otype T ) T * malloc( char fill );
    42734335forall( otype T ) T * malloc( T * ptr, size_t size );
    42744336forall( otype T ) T * malloc( T * ptr, size_t size, unsigned char fill );
    4275 forall( otype T ) T * calloc( size_t nmemb );§\indexc{calloc}§
    4276 forall( otype T ) T * realloc( T * ptr, size_t size );§\indexc{ato}§
     4337forall( otype T ) T * calloc( size_t size );
     4338forall( otype T ) T * realloc( T * ptr, size_t size );
    42774339forall( otype T ) T * realloc( T * ptr, size_t size, unsigned char fill );
    42784340
    4279 forall( otype T ) T * aligned_alloc( size_t alignment );§\indexc{ato}§
     4341forall( otype T ) T * aligned_alloc( size_t alignment );
    42804342forall( otype T ) T * memalign( size_t alignment );             // deprecated
    42814343forall( otype T ) int posix_memalign( T ** ptr, size_t alignment );
     
    42864348
    42874349
    4288 \subsection{ato / strto}
    4289 
    4290 \begin{lstlisting}
    4291 int ato( const char * ptr );§\indexc{ato}§
     4350\subsection{ato/strto}
     4351
     4352\begin{lstlisting}
     4353int ato( const char * ptr );
    42924354unsigned int ato( const char * ptr );
    42934355long int ato( const char * ptr );
     
    43174379
    43184380
    4319 \subsection{bsearch / qsort}
     4381\subsection{bsearch/qsort}
    43204382
    43214383\begin{lstlisting}
    43224384forall( otype T | { int ?<?( T, T ); } )
    4323 T * bsearch( const T key, const T * arr, size_t dimension );§\indexc{bsearch}§
     4385T * bsearch( const T key, const T * arr, size_t dimension );
    43244386
    43254387forall( otype T | { int ?<?( T, T ); } )
    4326 void qsort( const T * arr, size_t dimension );§\indexc{qsort}§
     4388void qsort( const T * arr, size_t dimension );
    43274389\end{lstlisting}
    43284390
     
    43314393
    43324394\begin{lstlisting}
    4333 char abs( char );§\indexc{abs}§
    4334 int abs( int );
     4395char abs( char );
     4396extern "C" {
     4397int abs( int );                         // use default C routine for int
     4398} // extern "C"
    43354399long int abs( long int );
    43364400long long int abs( long long int );
     
    43384402double abs( double );
    43394403long double abs( long double );
    4340 float abs( float _Complex );
    4341 double abs( double _Complex );
    4342 long double abs( long double _Complex );
     4404float _Complex abs( float _Complex );
     4405double _Complex abs( double _Complex );
     4406long double _Complex abs( long double _Complex );
     4407\end{lstlisting}
     4408
     4409
     4410\subsection{floor/ceil}
     4411
     4412\begin{lstlisting}
     4413float floor( float );
     4414extern "C" {
     4415double floor( double );         // use C routine for double
     4416} // extern "C"
     4417long double floor( long double );
     4418
     4419float ceil( float );
     4420extern "C" {
     4421double ceil( double );          // use C routine for double
     4422} // extern "C"
     4423long double ceil( long double );
    43434424\end{lstlisting}
    43444425
     
    43474428
    43484429\begin{lstlisting}
    4349 void rand48seed( long int s );§\indexc{rand48seed}§
    4350 char rand48();§\indexc{rand48}§
     4430void rand48seed( long int s );
     4431char rand48();
    43514432int rand48();
    43524433unsigned int rand48();
     
    43614442
    43624443
    4363 \subsection{min / max / swap}
     4444\subsection{min/max/swap}
    43644445
    43654446\begin{lstlisting}
    43664447forall( otype T | { int ?<?( T, T ); } )
    4367 T min( const T t1, const T t2 );§\indexc{min}§
     4448T min( const T t1, const T t2 );
    43684449
    43694450forall( otype T | { int ?>?( T, T ); } )
    4370 T max( const T t1, const T t2 );§\indexc{max}§
     4451T max( const T t1, const T t2 );
    43714452
    43724453forall( otype T )
    4373 void swap( T * t1, T * t2 );§\indexc{swap}§
    4374 \end{lstlisting}
    4375 
    4376 
    4377 \section{Math Library}
    4378 \label{s:Math Library}
    4379 
    4380 The goal of the \CFA math-library is to wrap many of the existing C math library-routines that are explicitly polymorphic into implicitly polymorphic versions.
    4381 
    4382 
    4383 \subsection{General}
    4384 
    4385 \begin{lstlisting}
    4386 float fabs( float );§\indexc{fabs}§
    4387 double fabs( double );
    4388 long double fabs( long double );
    4389 float cabs( float _Complex );
    4390 double cabs( double _Complex );
    4391 long double cabs( long double _Complex );
    4392 
    4393 float ?%?( float, float );§\indexc{fmod}§
    4394 float fmod( float, float );
    4395 double ?%?( double, double );
    4396 double fmod( double, double );
    4397 long double ?%?( long double, long double );
    4398 long double fmod( long double, long double );
    4399 
    4400 float remainder( float, float );§\indexc{remainder}§
    4401 double remainder( double, double );
    4402 long double remainder( long double, long double );
    4403 
    4404 [ int, float ] remquo( float, float );§\indexc{remquo}§
    4405 float remquo( float, float, int * );
    4406 [ int, double ] remquo( double, double );
    4407 double remquo( double, double, int * );
    4408 [ int, long double ] remquo( long double, long double );
    4409 long double remquo( long double, long double, int * );
    4410 
    4411 [ int, float ] div( float, float );                                             // alternative name for remquo
    4412 float div( float, float, int * );§\indexc{div}§
    4413 [ int, double ] div( double, double );
    4414 double div( double, double, int * );
    4415 [ int, long double ] div( long double, long double );
    4416 long double div( long double, long double, int * );
    4417 
    4418 float fma( float, float, float );§\indexc{fma}§
    4419 double fma( double, double, double );
    4420 long double fma( long double, long double, long double );
    4421 
    4422 float fdim( float, float );§\indexc{fdim}§
    4423 double fdim( double, double );
    4424 long double fdim( long double, long double );
    4425 
    4426 float nan( const char * );§\indexc{nan}§
    4427 double nan( const char * );
    4428 long double nan( const char * );
    4429 \end{lstlisting}
    4430 
    4431 
    4432 \subsection{Exponential}
    4433 
    4434 \begin{lstlisting}
    4435 float exp( float );§\indexc{exp}§
    4436 double exp( double );
    4437 long double exp( long double );
    4438 float _Complex exp( float _Complex );
    4439 double _Complex exp( double _Complex );
    4440 long double _Complex exp( long double _Complex );
    4441 
    4442 float exp2( float );§\indexc{exp2}§
    4443 double exp2( double );
    4444 long double exp2( long double );
    4445 float _Complex exp2( float _Complex );
    4446 double _Complex exp2( double _Complex );
    4447 long double _Complex exp2( long double _Complex );
    4448 
    4449 float expm1( float );§\indexc{expm1}§
    4450 double expm1( double );
    4451 long double expm1( long double );
    4452 
    4453 float log( float );§\indexc{log}§
    4454 double log( double );
    4455 long double log( long double );
    4456 float _Complex log( float _Complex );
    4457 double _Complex log( double _Complex );
    4458 long double _Complex log( long double _Complex );
    4459 
    4460 float log2( float );§\indexc{log2}§
    4461 double log2( double );
    4462 long double log2( long double );
    4463 float _Complex log2( float _Complex );
    4464 double _Complex log2( double _Complex );
    4465 long double _Complex log2( long double _Complex );
    4466 
    4467 float log10( float );§\indexc{log10}§
    4468 double log10( double );
    4469 long double log10( long double );
    4470 float _Complex log10( float _Complex );
    4471 double _Complex log10( double _Complex );
    4472 long double _Complex log10( long double _Complex );
    4473 
    4474 float log1p( float );§\indexc{log1p}§
    4475 double log1p( double );
    4476 long double log1p( long double );
    4477 
    4478 int ilogb( float );§\indexc{ilogb}§
    4479 int ilogb( double );
    4480 int ilogb( long double );
    4481 
    4482 float logb( float );§\indexc{logb}§
    4483 double logb( double );
    4484 long double logb( long double );
    4485 \end{lstlisting}
    4486 
    4487 
    4488 \subsection{Power}
    4489 
    4490 \begin{lstlisting}
    4491 float sqrt( float );§\indexc{sqrt}§
    4492 double sqrt( double );
    4493 long double sqrt( long double );
    4494 float _Complex sqrt( float _Complex );
    4495 double _Complex sqrt( double _Complex );
    4496 long double _Complex sqrt( long double _Complex );
    4497 
    4498 float cbrt( float );§\indexc{cbrt}§
    4499 double cbrt( double );
    4500 long double cbrt( long double );
    4501 
    4502 float hypot( float, float );§\indexc{hypot}§
    4503 double hypot( double, double );
    4504 long double hypot( long double, long double );
    4505 
    4506 float pow( float, float );§\indexc{pow}§
    4507 double pow( double, double );
    4508 long double pow( long double, long double );
    4509 float _Complex pow( float _Complex, float _Complex );
    4510 double _Complex pow( double _Complex, double _Complex );
    4511 long double _Complex pow( long double _Complex, long double _Complex );
    4512 \end{lstlisting}
    4513 
    4514 
    4515 \subsection{Trigonometric}
    4516 
    4517 \begin{lstlisting}
    4518 float sin( float );§\indexc{sin}§
    4519 double sin( double );
    4520 long double sin( long double );
    4521 float _Complex sin( float _Complex );
    4522 double _Complex sin( double _Complex );
    4523 long double _Complex sin( long double _Complex );
    4524 
    4525 float cos( float );§\indexc{cos}§
    4526 double cos( double );
    4527 long double cos( long double );
    4528 float _Complex cos( float _Complex );
    4529 double _Complex cos( double _Complex );
    4530 long double _Complex cos( long double _Complex );
    4531 
    4532 float tan( float );§\indexc{tan}§
    4533 double tan( double );
    4534 long double tan( long double );
    4535 float _Complex tan( float _Complex );
    4536 double _Complex tan( double _Complex );
    4537 long double _Complex tan( long double _Complex );
    4538 
    4539 float asin( float );§\indexc{asin}§
    4540 double asin( double );
    4541 long double asin( long double );
    4542 float _Complex asin( float _Complex );
    4543 double _Complex asin( double _Complex );
    4544 long double _Complex asin( long double _Complex );
    4545 
    4546 float acos( float );§\indexc{acos}§
    4547 double acos( double );
    4548 long double acos( long double );
    4549 float _Complex acos( float _Complex );
    4550 double _Complex acos( double _Complex );
    4551 long double _Complex acos( long double _Complex );
    4552 
    4553 float atan( float );§\indexc{atan}§
    4554 double atan( double );
    4555 long double atan( long double );
    4556 float _Complex atan( float _Complex );
    4557 double _Complex atan( double _Complex );
    4558 long double _Complex atan( long double _Complex );
    4559 
    4560 float atan2( float, float );§\indexc{atan2}§
    4561 double atan2( double, double );
    4562 long double atan2( long double, long double );
    4563 
    4564 float atan( float, float );                                                             // alternative name for atan2
    4565 double atan( double, double );§\indexc{atan}§
    4566 long double atan( long double, long double );
    4567 \end{lstlisting}
    4568 
    4569 
    4570 \subsection{Hyperbolic}
    4571 
    4572 \begin{lstlisting}
    4573 float sinh( float );§\indexc{sinh}§
    4574 double sinh( double );
    4575 long double sinh( long double );
    4576 float _Complex sinh( float _Complex );
    4577 double _Complex sinh( double _Complex );
    4578 long double _Complex sinh( long double _Complex );
    4579 
    4580 float cosh( float );§\indexc{cosh}§
    4581 double cosh( double );
    4582 long double cosh( long double );
    4583 float _Complex cosh( float _Complex );
    4584 double _Complex cosh( double _Complex );
    4585 long double _Complex cosh( long double _Complex );
    4586 
    4587 float tanh( float );§\indexc{tanh}§
    4588 double tanh( double );
    4589 long double tanh( long double );
    4590 float _Complex tanh( float _Complex );
    4591 double _Complex tanh( double _Complex );
    4592 long double _Complex tanh( long double _Complex );
    4593 
    4594 float asinh( float );§\indexc{asinh}§
    4595 double asinh( double );
    4596 long double asinh( long double );
    4597 float _Complex asinh( float _Complex );
    4598 double _Complex asinh( double _Complex );
    4599 long double _Complex asinh( long double _Complex );
    4600 
    4601 float acosh( float );§\indexc{acosh}§
    4602 double acosh( double );
    4603 long double acosh( long double );
    4604 float _Complex acosh( float _Complex );
    4605 double _Complex acosh( double _Complex );
    4606 long double _Complex acosh( long double _Complex );
    4607 
    4608 float atanh( float );§\indexc{atanh}§
    4609 double atanh( double );
    4610 long double atanh( long double );
    4611 float _Complex atanh( float _Complex );
    4612 double _Complex atanh( double _Complex );
    4613 long double _Complex atanh( long double _Complex );
    4614 \end{lstlisting}
    4615 
    4616 
    4617 \subsection{Error / Gamma}
    4618 
    4619 \begin{lstlisting}
    4620 float erf( float );§\indexc{erf}§
    4621 double erf( double );
    4622 long double erf( long double );
    4623 float _Complex erf( float _Complex );
    4624 double _Complex erf( double _Complex );
    4625 long double _Complex erf( long double _Complex );
    4626 
    4627 float erfc( float );§\indexc{erfc}§
    4628 double erfc( double );
    4629 long double erfc( long double );
    4630 float _Complex erfc( float _Complex );
    4631 double _Complex erfc( double _Complex );
    4632 long double _Complex erfc( long double _Complex );
    4633 
    4634 float lgamma( float );§\indexc{lgamma}§
    4635 double lgamma( double );
    4636 long double lgamma( long double );
    4637 float lgamma( float, int * );
    4638 double lgamma( double, int * );
    4639 long double lgamma( long double, int * );
    4640 
    4641 float tgamma( float );§\indexc{tgamma}§
    4642 double tgamma( double );
    4643 long double tgamma( long double );
    4644 \end{lstlisting}
    4645 
    4646 
    4647 \subsection{Nearest Integer}
    4648 
    4649 \begin{lstlisting}
    4650 float floor( float );§\indexc{floor}§
    4651 double floor( double );
    4652 long double floor( long double );
    4653 
    4654 float ceil( float );§\indexc{ceil}§
    4655 double ceil( double );
    4656 long double ceil( long double );
    4657 
    4658 float trunc( float );§\indexc{trunc}§
    4659 double trunc( double );
    4660 long double trunc( long double );
    4661 
    4662 float rint( float );§\indexc{rint}§
    4663 long double rint( long double );
    4664 long int rint( float );
    4665 long int rint( double );
    4666 long int rint( long double );
    4667 long long int rint( float );
    4668 long long int rint( double );
    4669 long long int rint( long double );
    4670 
    4671 long int lrint( float );§\indexc{lrint}§
    4672 long int lrint( double );
    4673 long int lrint( long double );
    4674 long long int llrint( float );
    4675 long long int llrint( double );
    4676 long long int llrint( long double );
    4677 
    4678 float nearbyint( float );§\indexc{nearbyint}§
    4679 double nearbyint( double );
    4680 long double nearbyint( long double );
    4681 
    4682 float round( float );§\indexc{round}§
    4683 long double round( long double );
    4684 long int round( float );
    4685 long int round( double );
    4686 long int round( long double );
    4687 long long int round( float );
    4688 long long int round( double );
    4689 long long int round( long double );
    4690 
    4691 long int lround( float );§\indexc{lround}§
    4692 long int lround( double );
    4693 long int lround( long double );
    4694 long long int llround( float );
    4695 long long int llround( double );
    4696 long long int llround( long double );
    4697 \end{lstlisting}
    4698 
    4699 
    4700 \subsection{Manipulation}
    4701 
    4702 \begin{lstlisting}
    4703 float copysign( float, float );§\indexc{copysign}§
    4704 double copysign( double, double );
    4705 long double copysign( long double, long double );
    4706 
    4707 float frexp( float, int * );§\indexc{frexp}§
    4708 double frexp( double, int * );
    4709 long double frexp( long double, int * );
    4710 
    4711 float ldexp( float, int );§\indexc{ldexp}§
    4712 double ldexp( double, int );
    4713 long double ldexp( long double, int );
    4714 
    4715 [ float, float ] modf( float );§\indexc{modf}§
    4716 float modf( float, float * );
    4717 [ double, double ] modf( double );
    4718 double modf( double, double * );
    4719 [ long double, long double ] modf( long double );
    4720 long double modf( long double, long double * );
    4721 
    4722 float nextafter( float, float );§\indexc{nextafter}§
    4723 double nextafter( double, double );
    4724 long double nextafter( long double, long double );
    4725 
    4726 float nexttoward( float, long double );§\indexc{nexttoward}§
    4727 double nexttoward( double, long double );
    4728 long double nexttoward( long double, long double );
    4729 
    4730 float scalbn( float, int );§\indexc{scalbn}§
    4731 double scalbn( double, int );
    4732 long double scalbn( long double, int );
    4733 
    4734 float scalbln( float, long int );§\indexc{scalbln}§
    4735 double scalbln( double, long int );
    4736 long double scalbln( long double, long int );
     4454void swap( T * t1, T * t2 );
    47374455\end{lstlisting}
    47384456
     
    47464464\begin{lstlisting}
    47474465// implementation
    4748 struct Rational {§\indexc{Rational}§
     4466struct Rational {
    47494467        long int numerator, denominator;                                        // invariant: denominator > 0
    47504468}; // Rational
Note: See TracChangeset for help on using the changeset viewer.