Changeset 58ed882 for doc/user/user.tex


Ignore:
Timestamp:
May 24, 2017, 10:48:02 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
0a208b8, 64fc0ba, bc37a83
Parents:
8dc51c8
Message:

many updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    r8dc51c8 r58ed882  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Sun May 21 23:36:42 2017
    14 %% Update Count     : 1822
     13%% Last Modified On : Wed May 24 22:21:42 2017
     14%% Update Count     : 1994
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    151151
    152152Like \Index*[C++]{\CC}, there may be both an old and new ways to achieve the same effect.
    153 For example, the following programs compare the \CFA and C I/O mechanisms.
     153For example, the following programs compare the \CFA, C, nad \CC I/O mechanisms, where the programs output the same result.
    154154\begin{quote2}
    155155\begin{tabular}{@{}l@{\hspace{1.5em}}l@{\hspace{1.5em}}l@{}}
     
    183183\end{tabular}
    184184\end{quote2}
    185 The programs output the same result.
    186185While the \CFA I/O looks similar to the \Index*[C++]{\CC} output style, there are important differences, such as automatic spacing between variables as in \Index*{Python} (see~\VRef{s:IOLibrary}).
    187186
     
    14261425
    14271426
    1428 \section{Type/Routine Nesting}
     1427\section{Unnamed Structure Fields}
     1428
     1429C requires each field of a structure to have a name, except for a bit field associated with a basic type, \eg:
     1430\begin{cfa}
     1431struct {
     1432        int f1;                                 §\C{// named field}§
     1433        int f2 : 4;                             §\C{// named field with bit field size}§
     1434        int : 3;                                §\C{// unnamed field for basic type with bit field size}§
     1435        int ;                                   §\C{// disallowed, unnamed field}§
     1436        int *;                                  §\C{// disallowed, unnamed field}§
     1437        int (*)(int);                   §\C{// disallowed, unnamed field}§
     1438};
     1439\end{cfa}
     1440This requirement is relaxed by making the field name optional for all field declarations; therefore, all the field declarations in the example are allowed.
     1441As for unnamed bit fields, an unnamed field is used for padding a structure to a particular size.
     1442A list of unnamed fields is also supported, \eg:
     1443\begin{cfa}
     1444struct {
     1445        int , , ;                               §\C{// 3 unnamed fields}§
     1446}
     1447\end{cfa}
     1448
     1449
     1450\section{Nesting}
    14291451
    14301452Nesting of types and routines is useful for controlling name visibility (\newterm{name hiding}).
     
    17961818
    17971819
    1798 \section{Unnamed Structure Fields}
    1799 
    1800 C requires each field of a structure to have a name, except for a bit field associated with a basic type, \eg:
    1801 \begin{cfa}
    1802 struct {
    1803         int f1;                                 §\C{// named field}§
    1804         int f2 : 4;                             §\C{// named field with bit field size}§
    1805         int : 3;                                §\C{// unnamed field for basic type with bit field size}§
    1806         int ;                                   §\C{// disallowed, unnamed field}§
    1807         int *;                                  §\C{// disallowed, unnamed field}§
    1808         int (*)(int);                   §\C{// disallowed, unnamed field}§
    1809 };
    1810 \end{cfa}
    1811 This requirement is relaxed by making the field name optional for all field declarations; therefore, all the field declarations in the example are allowed.
    1812 As for unnamed bit fields, an unnamed field is used for padding a structure to a particular size.
    1813 A list of unnamed fields is also supported, \eg:
    1814 \begin{cfa}
    1815 struct {
    1816         int , , ;                               §\C{// 3 unnamed fields}§
    1817 }
    1818 \end{cfa}
    1819 
    1820 
    18211820\section{Field Tuples}
    18221821
     
    18611860
    18621861While C provides ©continue© and ©break© statements for altering control flow, both are restricted to one level of nesting for a particular control structure.
    1863 Unfortunately, this restriction forces programmers to use ©goto© to achieve the equivalent control-flow for more than one level of nesting.
    1864 To prevent having to switch to the ©goto©, \CFA extends the ©continue©\index{continue@©continue©}\index{continue@©continue©!labelled}\index{labelled!continue@©continue©} and ©break©\index{break@©break©}\index{break@©break©!labelled}\index{labelled!break@©break©} with a target label to support static multi-level exit\index{multi-level exit}\index{static multi-level exit}~\cite{Buhr85,Java}.
     1862Unfortunately, this restriction forces programmers to use \Indexc{goto} to achieve the equivalent control-flow for more than one level of nesting.
     1863To prevent having to switch to the ©goto©, \CFA extends the \Indexc{continue}\index{continue@©continue©!labelled}\index{labelled!continue@©continue©} and \Indexc{break}\index{break@©break©!labelled}\index{labelled!break@©break©} with a target label to support static multi-level exit\index{multi-level exit}\index{static multi-level exit}~\cite{Buhr85,Java}.
    18651864For both ©continue© and ©break©, the target label must be directly associated with a ©for©, ©while© or ©do© statement;
    18661865for ©break©, the target label can also be associated with a ©switch©, ©if© or compound (©{}©) statement.
    1867 
    1868 The following example shows the labelled ©continue© specifying which control structure is the target for the next loop iteration:
    1869 \begin{quote2}
    1870 \begin{tabular}{@{}l@{\hspace{3em}}l@{}}
    1871 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c}{\textbf{C}}        \\
    1872 \begin{cfa}
    1873 ®L1:® do {
    1874         ®L2:® while ( ... ) {
    1875                 ®L3:® for ( ... ) {
    1876                         ... continue ®L1®; ...  // continue do
    1877                         ... continue ®L2®; ...  // continue while
    1878                         ... continue ®L3®; ...  // continue for
    1879                 } // for
    1880         } // while
    1881 } while ( ... );
    1882 \end{cfa}
    1883 &
    1884 \begin{cfa}
    1885 do {
    1886         while ( ... ) {
    1887                 for ( ... ) {
    1888                         ... goto L1; ...
    1889                         ... goto L2; ...
    1890                         ... goto L3; ...
    1891                 L3: ; }
    1892         L2: ; }
    1893 L1: ; } while ( ... );
    1894 \end{cfa}
    1895 \end{tabular}
    1896 \end{quote2}
    1897 The innermost loop has three restart points, which cause the next loop iteration to begin.
    1898 
    1899 The following example shows the labelled ©break© specifying which control structure is the target for exit:
    1900 \begin{quote2}
    1901 \begin{tabular}{@{}l@{\hspace{3em}}l@{}}
    1902 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c}{\textbf{C}}        \\
    1903 \begin{cfa}
    1904 ®L1:® {
     1866\VRef[Figure]{f:MultiLevelResumeTermination} shows the labelled ©continue© and ©break©, specifying which control structure is the target for exit, and the corresponding C program using only ©goto©.
     1867The innermost loop has 7 exit points, which cause resumption or termination of one or more of the 7 \Index{nested control-structure}s.
     1868
     1869\begin{figure}
     1870\begin{tabular}{@{\hspace{\parindentlnth}}l@{\hspace{1.5em}}l@{}}
     1871\multicolumn{1}{c@{\hspace{1.5em}}}{\textbf{\CFA}}      & \multicolumn{1}{c}{\textbf{C}}        \\
     1872\begin{cfa}
     1873®LC:® {
    19051874        ... §declarations§ ...
    1906         ®L2:® switch ( ... ) {
     1875        ®LS:® switch ( ... ) {
    19071876          case 3:
    1908             ®L3:® if ( ... ) {
    1909                         ®L4:® for ( ... ) {
    1910                                 ... break ®L1®; ...     // exit compound statement
    1911                                 ... break ®L2®; ...     // exit switch
    1912                                 ... break ®L3®; ...     // exit if
    1913                                 ... break ®L4®; ...     // exit loop
     1877                ®LIF:® if ( ... ) {
     1878                        ®LF:® for ( ... ) {
     1879                                ®LW:® while ( ... ) {
     1880                                        ... break ®LC®; ...                     // terminate compound
     1881                                        ... break ®LS®; ...                     // terminate switch
     1882                                        ... break ®LIF®; ...                    // terminate if
     1883                                        ... continue ®LF;® ...   // resume loop
     1884                                        ... break ®LF®; ...                     // terminate loop
     1885                                        ... continue ®LW®; ...   // resume loop
     1886                                        ... break ®LW®; ...               // terminate loop
     1887                                } // while
    19141888                        } // for
    19151889                } else {
    1916                         ... break ®L3®; ...             // exit if
     1890                        ... break ®LIF®; ...                                     // terminate if
    19171891                } // if
    19181892        } // switch
     
    19251899        switch ( ... ) {
    19261900          case 3:
    1927             if ( ... ) {
     1901                if ( ... ) {
    19281902                        for ( ... ) {
    1929                                 ... goto L1; ...
    1930                                 ... goto L2; ...
    1931                                 ... goto L3; ...
    1932                                 ... goto L4; ...
    1933                         } L4: ;
     1903                                for ( ... ) {
     1904                                        ... goto ®LC®; ...
     1905                                        ... goto ®LS®; ...
     1906                                        ... goto ®LIF®; ...
     1907                                        ... goto ®LFC®; ...
     1908                                        ... goto ®LFB®; ...
     1909                                        ... goto ®LWC®; ...
     1910                                        ... goto ®LWB®; ...
     1911                                  ®LWC®: ; } ®LWB:® ;
     1912                          ®LFC:® ; } ®LFB:® ;
    19341913                } else {
    1935                         ... goto L3; ...
    1936                 } L3: ;
    1937         } L2: ;
    1938 } L1: ;
     1914                        ... goto ®LIF®; ...
     1915                } ®L3:® ;
     1916        } ®LS:® ;
     1917} ®LC:® ;
    19391918\end{cfa}
    19401919\end{tabular}
    1941 \end{quote2}
    1942 The innermost loop has four exit points, which cause termination of one or more of the four \Index{nested control structure}s.
    1943 
    1944 Both ©continue© and ©break© with target labels are simply a ©goto©\index{goto@©goto©!restricted} restricted in the following ways:
     1920\caption{Multi-level Resume/Termination}
     1921\label{f:MultiLevelResumeTermination}
     1922\end{figure}
     1923
     1924Both labelled ©continue© and ©break© are a ©goto©\index{goto@©goto©!restricted} restricted in the following ways:
    19451925\begin{itemize}
    19461926\item
    1947 They cannot be used to create a loop.
    1948 This means that only the looping construct can be used to create a loop.
    1949 This restriction is important since all situations that can result in repeated execution of statements in a program are clearly delineated.
    1950 \item
    1951 Since they always transfer out of containing control structures, they cannot be used to branch into a control structure.
     1927They cannot create a loop, which means only the looping constructs cause looping.
     1928This restriction means all situations resulting in repeated execution are clearly delineated.
     1929\item
     1930They cannot branch into a control structure.
     1931This restriction prevents missing initialization at the start of a control structure resulting in undefined behaviour.
    19521932\end{itemize}
    1953 The advantage of the labelled ©continue©/©break© is allowing static multi-level exits without having to use the ©goto© statement and tying control flow to the target control structure rather than an arbitrary point in a program.
     1933The advantage of the labelled ©continue©/©break© is allowing static multi-level exits without having to use the ©goto© statement, and tying control flow to the target control structure rather than an arbitrary point in a program.
    19541934Furthermore, the location of the label at the \emph{beginning} of the target control structure informs the reader that complex control-flow is occurring in the body of the control structure.
    19551935With ©goto©, the label is at the end of the control structure, which fails to convey this important clue early enough to the reader.
     
    22682248\index{input/output library}
    22692249
    2270 The goal for the \CFA I/O is to make I/O as simple as possible in the common cases, while fully supporting polymorphism and user defined types in a consistent way.
     2250The goal of \CFA I/O is to simplify the common cases\index{I/O!common case}, while fully supporting polymorphism and user defined types in a consistent way.
    22712251The common case is printing out a sequence of variables separated by whitespace.
    22722252\begin{quote2}
     
    22742254\multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c}{\textbf{\CC}}      \\
    22752255\begin{cfa}
    2276 int x = 0, y = 1, z = 2;
     2256int x = 1, y = 2, z = 3;
    22772257sout | x ®|® y ®|® z | endl;
    22782258\end{cfa}
     
    22812261
    22822262cout << x ®<< " "® << y ®<< " "® << z << endl;
     2263\end{cfa}
     2264\\
     2265\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     22661 2 3
     2267\end{cfa}
     2268&
     2269\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     22701 2 3
    22832271\end{cfa}
    22842272\end{tabular}
    22852273\end{quote2}
    22862274The \CFA form has half as many characters as the \CC form, and is similar to \Index*{Python} I/O with respect to implicit separators.
    2287 
    2288 The logical-or operator is used because it is the lowest-priority overloadable operator, other than assignment.
     2275A tuple prints all the tuple's values, each separated by ©", "©.
     2276\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2277[int, int] t1 = [1, 2], t2 = [3, 4];
     2278sout | t1 | t2 | endl;                                  §\C{// print tuples}§
     2279\end{cfa}
     2280\begin{cfa}[mathescape=off,showspaces=true,belowskip=0pt]
     22811, 2, 3, 4
     2282\end{cfa}
     2283\CFA uses the logical-or operator for I/O because it is the lowest-priority overloadable operator, other than assignment.
    22892284Therefore, fewer output expressions require parenthesis.
    22902285\begin{quote2}
     
    22992294&
    23002295\begin{cfa}
    2301 cout << x * 3 << y + 1 << (z << 2) << (x == y) << (x | y) << (x || y) << (x > z ? 1 : 2) << endl;
     2296cout << x * 3 << y + 1 << ®(®z << 2®)® << ®(®x == y®)® << (x | y) << (x || y) << (x > z ? 1 : 2) << endl;
     2297\end{cfa}
     2298\\
     2299&
     2300\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     23013 3 12 0 3 1 2
    23022302\end{cfa}
    23032303\end{tabular}
     
    23052305Finally, the logical-or operator has a link with the Shell pipe-operator for moving data, where data flows in the correct direction for input but the opposite direction for output.
    23062306
     2307
    23072308The implicit separator\index{I/O separator} character (space/blank) is a separator not a terminator.
    23082309The rules for implicitly adding the separator are:
     
    231623171 2 3
    23172318\end{cfa}
     2319
    23182320\item
    23192321A separator does not appear before or after a character literal or variable.
     
    23222324123
    23232325\end{cfa}
    2324 \item
    2325 A separator does not appear before or after a null (empty) C string
     2326
     2327\item
     2328A separator does not appear before or after a null (empty) C string.
    23262329\begin{cfa}
    23272330sout | 1 | "" | 2 | "" | 3 | endl;
     
    23292332\end{cfa}
    23302333which is a local mechanism to disable insertion of the separator character.
    2331 \item
    2332 A separator does not appear before a C string starting with the (extended) \Index{ASCII}\index{ASCII!extended} characters: \lstinline[mathescape=off]@([{=$£¥¡¿«@
     2334
     2335\item
     2336A separator does not appear before a C string starting with the (extended) \Index{ASCII}\index{ASCII!extended} characters: \lstinline[mathescape=off,basicstyle=\tt]@([{=$£¥¡¿«@
    23332337%$
    23342338\begin{cfa}[mathescape=off]
     
    23372341\end{cfa}
    23382342%$
    2339 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    2340 x (1 x [2 x {3 x =4 x $5 x £6 x ¥7 x ¡8 x ¿9 x «10
     2343\begin{cfa}[mathescape=off,basicstyle=\tt,showspaces=true,aboveskip=0pt,belowskip=0pt]
     2344x ®(®1 x ®[®2 x ®{®3 x ®=®4 x ®$®5 x ®£®6 x ®¥®7 x ®¡®8 x ®¿®9 x ®«®10
    23412345\end{cfa}
    23422346%$
     2347where \lstinline[basicstyle=\tt]@¡¿@ are inverted opening exclamation and question marks, and \lstinline[basicstyle=\tt]@«@ is an opening citation mark.
     2348
    23432349\item
    23442350{\lstset{language=CFA,deletedelim=**[is][]{¢}{¢}}
    2345 A seperator does not appear after a C string ending with the (extended) \Index{ASCII}\index{ASCII!extended} characters: ©,.;!?)]}%¢»©
     2351A seperator does not appear after a C string ending with the (extended) \Index{ASCII}\index{ASCII!extended} characters: \lstinline[basicstyle=\tt]@,.;!?)]}%¢»@
    23462352\begin{cfa}[belowskip=0pt]
    23472353sout | 1 | ", x" | 2 | ". x" | 3 | "; x" | 4 | "! x" | 5 | "? x" | 6 | "% x"
    23482354                | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x" | endl;
    23492355\end{cfa}
    2350 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    2351 1, x 2. x 3; x 4! x 5? x 6% x 7§\textcent§ x 8» x 9) x 10] x 11} x
     2356\begin{cfa}[basicstyle=\tt,showspaces=true,aboveskip=0pt,belowskip=0pt]
     23571®,® x 2®.® x 3®;® x 4®!® x 5®?® x 6®%® x 7§\color{red}\textcent§ x 8®»® x 9®)® x 10®]® x 11®}® x
    23522358\end{cfa}}%
    2353 \item
    2354 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@
     2359where \lstinline[basicstyle=\tt]@»@ is a closing citation mark.
     2360
     2361\item
     2362A seperator does not appear before or after a C string begining/ending with the \Index{ASCII} quote or whitespace characters: \lstinline[basicstyle=\tt,showspaces=true]@`'": \t\v\f\r\n@
    23552363\begin{cfa}[belowskip=0pt]
    23562364sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x:" | 4 | ":x " | 5 | " x\t" | 6 | "\tx" | endl;
    23572365\end{cfa}
    2358 \begin{cfa}[mathescape=off,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt]
    2359 x`1`x'2'x"3"x:4:x 5 x   6       x
     2366\begin{cfa}[basicstyle=\tt,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt]
     2367x®`®1®`®x§\color{red}\texttt{'}§2§\color{red}\texttt{'}§x§\color{red}\texttt{"}§3§\color{red}\texttt{"}§x®:®4®:®x® ®5® ®x®      ®6®     ®x
     2368\end{cfa}
     2369
     2370\item
     2371If a space is desired before or after one of the special string start/end characters, simply insert a space.
     2372\begin{cfa}[belowskip=0pt]
     2373sout | "x (§\color{red}\texttt{\textvisiblespace}§" | 1 | "§\color{red}\texttt{\textvisiblespace}§) x" | 2 | "§\color{red}\texttt{\textvisiblespace}§, x" | 3 | "§\color{red}\texttt{\textvisiblespace}§:x:§\color{red}\texttt{\textvisiblespace}§" | 4 | endl;
     2374\end{cfa}
     2375\begin{cfa}[basicstyle=\tt,showspaces=true,showtabs=true,aboveskip=0pt,belowskip=0pt]
     2376x (® ®1® ®) x 2® ®, x 3® ®:x:® ®4
    23602377\end{cfa}
    23612378\end{enumerate}
    23622379
    2363 The following \CC-style \Index{manipulator}s allow control over implicit seperation.
     2380The following routines and \CC-style \Index{manipulator}s control implicit seperation.
     2381\begin{enumerate}
     2382\item
     2383Routines \Indexc{sepSet}\index{manipulator!sepSet@©sepSet©} and \Indexc{sepGet}\index{manipulator!sepGet@©sepGet©} set and get the separator string.
     2384The separator string can be at most 16 characters including the ©'\0'© string terminator (15 printable characters).
     2385\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2386sepSet( sout, ", $" );                                          §\C{// set separator from " " to ", \$"}§
     2387sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;
     2388\end{cfa}
     2389%$
     2390\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     23911, $2, $3 ®", $"®
     2392\end{cfa}
     2393%$
     2394\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2395sepSet( sout, " " );                                            §\C{// reset separator to " "}§
     2396sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;
     2397\end{cfa}
     2398\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     23991 2 3 ®" "®
     2400\end{cfa}
     2401
     2402\item
    23642403Manipulators \Indexc{sepOn}\index{manipulator!sepOn@©sepOn©} and \Indexc{sepOff}\index{manipulator!sepOff@©sepOff©} \emph{locally} toggle printing the separator, \ie the seperator is adjusted only with respect to the next printed item.
    23652404\begin{cfa}[mathescape=off,belowskip=0pt]
     
    2375241412 3
    23762415\end{cfa}
     2416
     2417\item
    23772418Manipulators \Indexc{sepDisable}\index{manipulator!sepDisable@©sepDisable©} and \Indexc{sepEnable}\index{manipulator!sepEnable@©sepEnable©} \emph{globally} toggle printing the separator, \ie the seperator is adjusted with respect to all subsequent printed items, unless locally adjusted.
    23782419\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     
    239424351 2 3
    23952436\end{cfa}
    2396 Printing a tuple outputs all the tuple's values separated by ©", "©:
     2437
     2438\item
     2439Routine \Indexc{sepSetTuple}\index{manipulator!sepSetTuple@©sepSetTuple©} and \Indexc{sepGetTuple}\index{manipulator!sepGetTuple@©sepGetTuple©} get and set the tuple separator-string.
     2440The tuple separator-string can be at most 16 characters including the ©'\0'© string terminator (15 printable characters).
    23972441\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    2398 sout | [2, 3] | [4, 5] | endl;                          §\C{// print tuple}§
     2442sepSetTuple( sout, " " );                                       §\C{// set tuple separator from ", " to " "}§
     2443sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;
     2444\end{cfa}
     2445\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     24461 2 3 4 ®" "®
     2447\end{cfa}
     2448\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2449sepSetTuple( sout, ", " );                                      §\C{// reset tuple separator to ", "}§
     2450sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;
     2451\end{cfa}
     2452\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     24531, 2, 3, 4 ®", "®
     2454\end{cfa}
     2455
     2456\item
     2457The tuple separator can also be turned on and off.
     2458\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2459sout | sepOn | t1 | sepOff | t2 | endl;         §\C{// locally turn on/off implicit separation}§
    23992460\end{cfa}
    24002461\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    2401 2, 3, 4, 5
    2402 \end{cfa}
    2403 The tuple separator can also be turned on and off:
    2404 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    2405 sout | sepOn | [2, 3] | sepOff | [4, 5] | endl; §\C{// locally turn on/off implicit separation}§
    2406 \end{cfa}
    2407 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    2408 , 2, 34, 5
     2462, 1, 23, 4
    24092463\end{cfa}
    24102464Notice a tuple seperator starts the line because the next item is a tuple.
    2411 Finally, the stream routines \Indexc{sepGet}\index{manipulator!sepGet@©sepGet©} and \Indexc{sepSet}\index{manipulator!sepSet@©sepSet©} get and set the basic separator-string.
    2412 \begin{cfa}[mathescape=off,aboveskip=0pt,aboveskip=0pt,belowskip=0pt]
    2413 sepSet( sout, ", $" );                                          §\C{// set separator from " " to ", \$"}§
    2414 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    2415 \end{cfa}
    2416 %$
    2417 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
    2418 1, $2, $3 ", $"
    2419 \end{cfa}
    2420 %$
    2421 \begin{cfa}[mathescape=off,aboveskip=0pt,aboveskip=0pt,belowskip=0pt]
    2422 sepSet( sout, " " );                                            §\C{// reset separator to " "}§
    2423 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    2424 \end{cfa}
    2425 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
    2426 1 2 3 " "
    2427 \end{cfa}
    2428 and the stream routines \Indexc{sepGetTuple}\index{manipulator!sepGetTuple@©sepGetTuple©} and \Indexc{sepSetTuple}\index{manipulator!sepSetTuple@©sepSetTuple©} get and set the tuple separator-string.
    2429 \begin{cfa}[mathescape=off,aboveskip=0pt,aboveskip=0pt,belowskip=0pt]
    2430 sepSetTuple( sout, " " );                                       §\C{// set tuple separator from ", " to " "}§
    2431 sout | [2, 3] | [4, 5] | " \"" | sepGetTuple( sout ) | "\"" | endl;
    2432 \end{cfa}
    2433 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
    2434 2 3 4 5 " "
    2435 \end{cfa}
    2436 \begin{cfa}[mathescape=off,aboveskip=0pt,aboveskip=0pt,belowskip=0pt]
    2437 sepSetTuple( sout, ", " );                                      §\C{// reset tuple separator to ", "}§
    2438 sout | [2, 3] | [4, 5] | " \"" | sepGetTuple( sout ) | "\"" | endl;
    2439 \end{cfa}
    2440 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
    2441 2, 3, 4, 5 ", "
    2442 \end{cfa}
     2465\end{enumerate}
    24432466
    24442467\begin{comment}
     
    24462469
    24472470int main( void ) {
    2448         int x = 0, y = 1, z = 2;
    2449         sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl | endl;
     2471        int x = 1, y = 2, z = 3;
     2472        sout | x | y | z | endl;
     2473        [int, int] t1 = [1, 2], t2 = [3, 4];
     2474        sout | t1 | t2 | endl;                                          // print tuple
     2475        sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;
    24502476        sout | 1 | 2 | 3 | endl;
    24512477        sout | '1' | '2' | '3' | endl;
     
    24562482                | 7 | "¢ x" | 8 | "» x" | 9 | ") x" | 10 | "] x" | 11 | "} x" | endl;
    24572483        sout | "x`" | 1 | "`x'" | 2 | "'x\"" | 3 | "\"x:" | 4 | ":x " | 5 | " x\t" | 6 | "\tx" | endl;
    2458 
    2459         sout | sepOn | 1 | 2 | 3 | sepOn | endl;        // separator at start of line
    2460         sout | 1 | sepOff | 2 | 3 | endl;                       // locally turn off implicit separator
    2461         sout | sepDisable | 1 | 2 | 3 | endl;           // globally turn off implicit separation
    2462         sout | 1 | sepOn | 2 | 3 | endl;                        // locally turn on implicit separator
    2463         sout | sepEnable | 1 | 2 | 3 | endl;            // globally turn on implicit separation
    2464 
    2465         sout | [2, 3] | [4, 5] | endl;                          // print tuple
    2466         sout | sepOn | [2, 3] | sepOff | [4, 5] | endl; // locally turn on/off implicit separation
     2484        sout | "x ( " | 1 | " ) x" | 2 | " , x" | 3 | " :x: " | 4 | endl;
    24672485
    24682486        sepSet( sout, ", $" );                                          // set separator from " " to ", $"
     
    24712489        sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    24722490
     2491        sout | sepOn | 1 | 2 | 3 | sepOn | endl;        // separator at start of line
     2492        sout | 1 | sepOff | 2 | 3 | endl;                       // locally turn off implicit separator
     2493
     2494        sout | sepDisable | 1 | 2 | 3 | endl;           // globally turn off implicit separation
     2495        sout | 1 | sepOn | 2 | 3 | endl;                        // locally turn on implicit separator
     2496        sout | sepEnable | 1 | 2 | 3 | endl;            // globally turn on implicit separation
     2497
    24732498        sepSetTuple( sout, " " );                                       // set tuple separator from ", " to " "
    2474         sout | [2, 3] | [4, 5] | " \"" | sepGetTuple( sout ) | "\"" | endl;
     2499        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
    24752500        sepSetTuple( sout, ", " );                                      // reset tuple separator to ", "
    2476         sout | [2, 3] | [4, 5] | " \"" | sepGetTuple( sout ) | "\"" | endl;
     2501        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
     2502
     2503        sout | t1 | t2 | endl;                                          // print tuple
     2504        sout | sepOn | t1 | sepOff | t2 | endl;         // locally turn on/off implicit separation
    24772505}
    24782506
    24792507// Local Variables: //
    24802508// tab-width: 4 //
     2509// fill-column: 100 //
    24812510// End: //
    24822511\end{comment}
     
    29723001generic (type T | bool ?<?(T, T) )
    29733002
    2974 T min(T a, T b) {
     3003T min( T a, T b ) {
    29753004        return a < b ? a : b;
    29763005}
     
    30113040
    30123041generic (type T | Orderable(T))
    3013 T min(T a, T b) {
     3042T min( T a, T b ) {
    30143043        return a < b ? a : b;
    30153044}
     
    50815110C11 prescribes the following standard header-files~\cite[\S~7.1.2]{C11} and \CFA adds to this list:
    50825111\begin{quote2}
    5083 \begin{tabular}{lll|l}
    5084 \multicolumn{3}{c|}{C11} & \multicolumn{1}{c}{\CFA}             \\
     5112\begin{tabular}{llll|l}
     5113\multicolumn{4}{c|}{C11} & \multicolumn{1}{c}{\CFA}             \\
    50855114\hline
    5086 assert.h        & math.h                & stdlib.h              & unistd.h      \\
    5087 complex.h       & setjmp.h              & stdnoreturn.h & gmp.h         \\
    5088 ctype.h         & signal.h              & string.h              \\
    5089 errno.h         & stdalign.h    & tgmath.h              \\
    5090 fenv.h          & stdarg.h              & threads.h             \\
    5091 float.h         & stdatomic.h   & time.h                \\
    5092 inttypes.h      & stdbool.h             & uchar.h               \\
    5093 iso646.h        & stddef.h              & wchar.h               \\
    5094 limits.h        & stdint.h              & wctype.h              \\
    5095 locale.h        & stdio.h               &                               \\
     5115\begin{tabular}{@{}l@{}}
     5116assert.h        \\
     5117complex.h       \\
     5118ctype.h         \\
     5119errno.h         \\
     5120fenv.h          \\
     5121float.h         \\
     5122inttypes.h      \\
     5123iso646.h        \\
     5124\end{tabular}
     5125&
     5126\begin{tabular}{@{}l@{}}
     5127limits.h        \\
     5128locale.h        \\
     5129math.h          \\
     5130setjmp.h        \\
     5131signal.h        \\
     5132stdalign.h      \\
     5133stdarg.h        \\
     5134stdatomic.h     \\
     5135\end{tabular}
     5136&
     5137\begin{tabular}{@{}l@{}}
     5138stdbool.h       \\
     5139stddef.h        \\
     5140stdint.h        \\
     5141stdio.h         \\
     5142stdlib.h        \\
     5143stdnoreturn.h \\
     5144string.h        \\
     5145tgmath.h        \\
     5146\end{tabular}
     5147&
     5148\begin{tabular}{@{}l@{}}
     5149threads.h       \\
     5150time.h          \\
     5151uchar.h         \\
     5152wchar.h         \\
     5153wctype.h        \\
     5154                        \\
     5155                        \\
     5156                        \\
     5157\end{tabular}
     5158&
     5159\begin{tabular}{@{}l@{}}
     5160unistd.h        \\
     5161gmp.h           \\
     5162                        \\
     5163                        \\
     5164                        \\
     5165                        \\
     5166                        \\
     5167                        \\
     5168\end{tabular}
    50965169\end{tabular}
    50975170\end{quote2}
     
    51045177\label{s:StandardLibrary}
    51055178
    5106 The \CFA standard-library wraps many existing explicitly-polymorphic C general-routines into implicitly-polymorphic versions.
     5179The \CFA standard-library wraps explicitly-polymorphic C general-routines into implicitly-polymorphic versions.
    51075180
    51085181
     
    51225195forall( dtype T | sized(T) ) T * memalign( size_t alignment );          // deprecated
    51235196forall( dtype T | sized(T) ) int posix_memalign( T ** ptr, size_t alignment );
    5124 
    5125 forall( otype T ) T * memset( T * ptr, unsigned char fill ); // use default value '\0' for fill
    5126 forall( otype T ) T * memset( T * ptr );                                // remove when default value available
    51275197
    51285198forall( dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); } ) T * new( Params p );
     
    51685238\leavevmode
    51695239\begin{cfa}[aboveskip=0pt,belowskip=0pt]
    5170 forall( otype T | { int ?<?( T, T ); } )
    5171 T * bsearch( const T key, const T * arr, size_t dimension );§\indexc{bsearch}§
     5240forall( otype T | { int ?<?( T, T ); } )        // location
     5241T * bsearch( T key, const T * arr, size_t dimension );§\indexc{bsearch}§
     5242
     5243forall( otype T | { int ?<?( T, T ); } )        // position
     5244unsigned int bsearch( T key, const T * arr, size_t dimension );
    51725245
    51735246forall( otype T | { int ?<?( T, T ); } )
     
    51805253\leavevmode
    51815254\begin{cfa}[aboveskip=0pt,belowskip=0pt]
    5182 char abs( char );§\indexc{abs}§
     5255unsigned char abs( signed char );§\indexc{abs}§
    51835256int abs( int );
    5184 long int abs( long int );
    5185 long long int abs( long long int );
     5257unsigned long int abs( long int );
     5258unsigned long long int abs( long long int );
    51865259float abs( float );
    51875260double abs( double );
     
    51905263double abs( double _Complex );
    51915264long double abs( long double _Complex );
     5265forall( otype T | { void ?{}( T *, zero_t ); int ?<?( T, T ); T -?( T ); } )
     5266T abs( T );
    51925267\end{cfa}
    51935268
     
    52165291\begin{cfa}[aboveskip=0pt,belowskip=0pt]
    52175292forall( otype T | { int ?<?( T, T ); } )
    5218 T min( const T t1, const T t2 );§\indexc{min}§
     5293T min( T t1, T t2 );§\indexc{min}§
    52195294
    52205295forall( otype T | { int ?>?( T, T ); } )
    5221 T max( const T t1, const T t2 );§\indexc{max}§
     5296T max( T t1, T t2 );§\indexc{max}§
    52225297
    52235298forall( otype T | { T min( T, T ); T max( T, T ); } )
     
    52325307\label{s:Math Library}
    52335308
    5234 The \CFA math-library wraps many existing explicitly-polymorphic C math-routines into implicitly-polymorphic versions.
     5309The \CFA math-library wraps explicitly-polymorphic C math-routines into implicitly-polymorphic versions.
    52355310
    52365311
     
    52395314\leavevmode
    52405315\begin{cfa}[aboveskip=0pt,belowskip=0pt]
    5241 float fabs( float );§\indexc{fabs}§
    5242 double fabs( double );
    5243 long double fabs( long double );
    5244 float cabs( float _Complex );
    5245 double cabs( double _Complex );
    5246 long double cabs( long double _Complex );
    5247 
    52485316float ?%?( float, float );§\indexc{fmod}§
    52495317float fmod( float, float );
     
    56005668
    56015669
     5670\section{Multi-precision Integers}
     5671\label{s:MultiPrecisionIntegers}
     5672
     5673\CFA has an interface to the \Index{GMP} \Index{multi-precision} signed-integers~\cite{GMP}, similar to the \CC interface provided by GMP.
     5674The \CFA interface wraps GMP routines into operator routines to make programming with multi-precision integers identical to using fixed-sized integers.
     5675The \CFA type name for multi-precision signed-integers is \Indexc{Int}.
     5676
     5677\begin{cfa}
     5678void ?{}( Int * this );                                 §\C{// constructor}§
     5679void ?{}( Int * this, Int init );
     5680void ?{}( Int * this, zero_t );
     5681void ?{}( Int * this, one_t );
     5682void ?{}( Int * this, signed long int init );
     5683void ?{}( Int * this, unsigned long int init );
     5684void ?{}( Int * this, const char * val );
     5685void ^?{}( Int * this );
     5686
     5687Int ?=?( Int * lhs, Int rhs );                  §\C{// assignment}§
     5688Int ?=?( Int * lhs, long int rhs );
     5689Int ?=?( Int * lhs, unsigned long int rhs );
     5690Int ?=?( Int * lhs, const char * rhs );
     5691
     5692char ?=?( char * lhs, Int rhs );
     5693short int ?=?( short int * lhs, Int rhs );
     5694int ?=?( int * lhs, Int rhs );
     5695long int ?=?( long int * lhs, Int rhs );
     5696unsigned char ?=?( unsigned char * lhs, Int rhs );
     5697unsigned short int ?=?( unsigned short int * lhs, Int rhs );
     5698unsigned int ?=?( unsigned int * lhs, Int rhs );
     5699unsigned long int ?=?( unsigned long int * lhs, Int rhs );
     5700
     5701long int narrow( Int val );
     5702unsigned long int narrow( Int val );
     5703
     5704int ?==?( Int oper1, Int oper2 );               §\C{// comparison}§
     5705int ?==?( Int oper1, long int oper2 );
     5706int ?==?( long int oper2, Int oper1 );
     5707int ?==?( Int oper1, unsigned long int oper2 );
     5708int ?==?( unsigned long int oper2, Int oper1 );
     5709
     5710int ?!=?( Int oper1, Int oper2 );
     5711int ?!=?( Int oper1, long int oper2 );
     5712int ?!=?( long int oper1, Int oper2 );
     5713int ?!=?( Int oper1, unsigned long int oper2 );
     5714int ?!=?( unsigned long int oper1, Int oper2 );
     5715
     5716int ?<?( Int oper1, Int oper2 );
     5717int ?<?( Int oper1, long int oper2 );
     5718int ?<?( long int oper2, Int oper1 );
     5719int ?<?( Int oper1, unsigned long int oper2 );
     5720int ?<?( unsigned long int oper2, Int oper1 );
     5721
     5722int ?<=?( Int oper1, Int oper2 );
     5723int ?<=?( Int oper1, long int oper2 );
     5724int ?<=?( long int oper2, Int oper1 );
     5725int ?<=?( Int oper1, unsigned long int oper2 );
     5726int ?<=?( unsigned long int oper2, Int oper1 );
     5727
     5728int ?>?( Int oper1, Int oper2 );
     5729int ?>?( Int oper1, long int oper2 );
     5730int ?>?( long int oper1, Int oper2 );
     5731int ?>?( Int oper1, unsigned long int oper2 );
     5732int ?>?( unsigned long int oper1, Int oper2 );
     5733
     5734int ?>=?( Int oper1, Int oper2 );
     5735int ?>=?( Int oper1, long int oper2 );
     5736int ?>=?( long int oper1, Int oper2 );
     5737int ?>=?( Int oper1, unsigned long int oper2 );
     5738int ?>=?( unsigned long int oper1, Int oper2 );
     5739
     5740Int +?( Int oper );                                             §\C{// arithmetic}§
     5741Int -?( Int oper );
     5742Int ~?( Int oper );
     5743
     5744Int ?&?( Int oper1, Int oper2 );
     5745Int ?&?( Int oper1, long int oper2 );
     5746Int ?&?( long int oper1, Int oper2 );
     5747Int ?&?( Int oper1, unsigned long int oper2 );
     5748Int ?&?( unsigned long int oper1, Int oper2 );
     5749Int ?&=?( Int * lhs, Int rhs );
     5750
     5751Int ?|?( Int oper1, Int oper2 );
     5752Int ?|?( Int oper1, long int oper2 );
     5753Int ?|?( long int oper1, Int oper2 );
     5754Int ?|?( Int oper1, unsigned long int oper2 );
     5755Int ?|?( unsigned long int oper1, Int oper2 );
     5756Int ?|=?( Int * lhs, Int rhs );
     5757
     5758Int ?^?( Int oper1, Int oper2 );
     5759Int ?^?( Int oper1, long int oper2 );
     5760Int ?^?( long int oper1, Int oper2 );
     5761Int ?^?( Int oper1, unsigned long int oper2 );
     5762Int ?^?( unsigned long int oper1, Int oper2 );
     5763Int ?^=?( Int * lhs, Int rhs );
     5764
     5765Int ?+?( Int addend1, Int addend2 );
     5766Int ?+?( Int addend1, long int addend2 );
     5767Int ?+?( long int addend2, Int addend1 );
     5768Int ?+?( Int addend1, unsigned long int addend2 );
     5769Int ?+?( unsigned long int addend2, Int addend1 );
     5770Int ?+=?( Int * lhs, Int rhs );
     5771Int ?+=?( Int * lhs, long int rhs );
     5772Int ?+=?( Int * lhs, unsigned long int rhs );
     5773Int ++?( Int * lhs );
     5774Int ?++( Int * lhs );
     5775
     5776Int ?-?( Int minuend, Int subtrahend );
     5777Int ?-?( Int minuend, long int subtrahend );
     5778Int ?-?( long int minuend, Int subtrahend );
     5779Int ?-?( Int minuend, unsigned long int subtrahend );
     5780Int ?-?( unsigned long int minuend, Int subtrahend );
     5781Int ?-=?( Int * lhs, Int rhs );
     5782Int ?-=?( Int * lhs, long int rhs );
     5783Int ?-=?( Int * lhs, unsigned long int rhs );
     5784Int --?( Int * lhs );
     5785Int ?--( Int * lhs );
     5786
     5787Int ?*?( Int multiplicator, Int multiplicand );
     5788Int ?*?( Int multiplicator, long int multiplicand );
     5789Int ?*?( long int multiplicand, Int multiplicator );
     5790Int ?*?( Int multiplicator, unsigned long int multiplicand );
     5791Int ?*?( unsigned long int multiplicand, Int multiplicator );
     5792Int ?*=?( Int * lhs, Int rhs );
     5793Int ?*=?( Int * lhs, long int rhs );
     5794Int ?*=?( Int * lhs, unsigned long int rhs );
     5795
     5796Int ?/?( Int dividend, Int divisor );
     5797Int ?/?( Int dividend, unsigned long int divisor );
     5798Int ?/?( unsigned long int dividend, Int divisor );
     5799Int ?/?( Int dividend, long int divisor );
     5800Int ?/?( long int dividend, Int divisor );
     5801Int ?/=?( Int * lhs, Int rhs );
     5802Int ?/=?( Int * lhs, long int rhs );
     5803Int ?/=?( Int * lhs, unsigned long int rhs );
     5804
     5805[ Int, Int ] div( Int dividend, Int divisor );
     5806[ Int, Int ] div( Int dividend, unsigned long int divisor );
     5807
     5808Int ?%?( Int dividend, Int divisor );
     5809Int ?%?( Int dividend, unsigned long int divisor );
     5810Int ?%?( unsigned long int dividend, Int divisor );
     5811Int ?%?( Int dividend, long int divisor );
     5812Int ?%?( long int dividend, Int divisor );
     5813Int ?%=?( Int * lhs, Int rhs );
     5814Int ?%=?( Int * lhs, long int rhs );
     5815Int ?%=?( Int * lhs, unsigned long int rhs );
     5816
     5817Int ?<<?( Int shiften, mp_bitcnt_t shift );
     5818Int ?<<=?( Int * lhs, mp_bitcnt_t shift );
     5819Int ?>>?( Int shiften, mp_bitcnt_t shift );
     5820Int ?>>=?( Int * lhs, mp_bitcnt_t shift );
     5821
     5822Int abs( Int oper );                                    §\C{// number functions}§
     5823Int fact( unsigned long int N );
     5824Int gcd( Int oper1, Int oper2 );
     5825Int pow( Int base, unsigned long int exponent );
     5826Int pow( unsigned long int base, unsigned long int exponent );
     5827void srandom( gmp_randstate_t state );
     5828Int random( gmp_randstate_t state, mp_bitcnt_t n );
     5829Int random( gmp_randstate_t state, Int n );
     5830Int random( gmp_randstate_t state, mp_size_t max_size );
     5831int sgn( Int oper );
     5832Int sqrt( Int oper );
     5833
     5834forall( dtype istype | istream( istype ) ) istype * ?|?( istype * is, Int * mp );  §\C{// I/O}§
     5835forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype * os, Int mp );
     5836\end{cfa}
     5837
     5838The following factorial programs contrast using GMP with the \CFA and C interfaces, where the output from these programs appears in \VRef[Figure]{f:MultiPrecisionFactorials}.
     5839(Compile with flag \Indexc{-lgmp} to link with the GMP library.)
     5840\begin{quote2}
     5841\begin{tabular}{@{}l@{\hspace{\parindentlnth}}|@{\hspace{\parindentlnth}}l@{}}
     5842\multicolumn{1}{c|@{\hspace{\parindentlnth}}}{\textbf{\CFA}}    & \multicolumn{1}{@{\hspace{\parindentlnth}}c}{\textbf{C}}      \\
     5843\hline
     5844\begin{cfa}
     5845#include <gmp>
     5846int main( void ) {
     5847        sout | "Factorial Numbers" | endl;
     5848        Int fact;
     5849        fact = 1;
     5850        sout | 0 | fact | endl;
     5851        for ( unsigned int i = 1; i <= 40; i += 1 ) {
     5852                fact *= i;
     5853                sout | i | fact | endl;
     5854        }
     5855}
     5856\end{cfa}
     5857&
     5858\begin{cfa}
     5859#include <gmp.h>
     5860int main( void ) {
     5861        ®gmp_printf®( "Factorial Numbers\n" );
     5862        ®mpz_t® fact;
     5863        ®mpz_init_set_ui®( fact, 1 );
     5864        ®gmp_printf®( "%d %Zd\n", 0, fact );
     5865        for ( unsigned int i = 1; i <= 40; i += 1 ) {
     5866                ®mpz_mul_ui®( fact, fact, i );
     5867                ®gmp_printf®( "%d %Zd\n", i, fact );
     5868        }
     5869}
     5870\end{cfa}
     5871\end{tabular}
     5872\end{quote2}
     5873
     5874\begin{figure}
     5875\begin{cfa}
     5876Factorial Numbers
     58770 1
     58781 1
     58792 2
     58803 6
     58814 24
     58825 120
     58836 720
     58847 5040
     58858 40320
     58869 362880
     588710 3628800
     588811 39916800
     588912 479001600
     589013 6227020800
     589114 87178291200
     589215 1307674368000
     589316 20922789888000
     589417 355687428096000
     589518 6402373705728000
     589619 121645100408832000
     589720 2432902008176640000
     589821 51090942171709440000
     589922 1124000727777607680000
     590023 25852016738884976640000
     590124 620448401733239439360000
     590225 15511210043330985984000000
     590326 403291461126605635584000000
     590427 10888869450418352160768000000
     590528 304888344611713860501504000000
     590629 8841761993739701954543616000000
     590730 265252859812191058636308480000000
     590831 8222838654177922817725562880000000
     590932 263130836933693530167218012160000000
     591033 8683317618811886495518194401280000000
     591134 295232799039604140847618609643520000000
     591235 10333147966386144929666651337523200000000
     591336 371993326789901217467999448150835200000000
     591437 13763753091226345046315979581580902400000000
     591538 523022617466601111760007224100074291200000000
     591639 20397882081197443358640281739902897356800000000
     591740 815915283247897734345611269596115894272000000000
     5918\end{cfa}
     5919\caption{Multi-precision Factorials}
     5920\label{f:MultiPrecisionFactorials}
     5921\end{figure}
     5922
     5923
    56025924\section{Rational Numbers}
    56035925\label{s:RationalNumbers}
     
    56125934}; // Rational
    56135935
    5614 // constants
    5615 extern struct Rational 0;
    5616 extern struct Rational 1;
    5617 
    5618 // constructors
    5619 Rational rational();
     5936Rational rational();                                    §\C{// constructors}§
    56205937Rational rational( long int n );
    56215938Rational rational( long int n, long int d );
    5622 
    5623 // getter/setter for numerator/denominator
    5624 long int numerator( Rational r );
     5939void ?{}( Rational * r, zero_t );
     5940void ?{}( Rational * r, one_t );
     5941
     5942long int numerator( Rational r );               §\C{// numerator/denominator getter/setter}§
    56255943long int numerator( Rational r, long int n );
    56265944long int denominator( Rational r );
    56275945long int denominator( Rational r, long int d );
    56285946
    5629 // comparison
    5630 int ?==?( Rational l, Rational r );
     5947int ?==?( Rational l, Rational r );             §\C{// comparison}§
    56315948int ?!=?( Rational l, Rational r );
    56325949int ?<?( Rational l, Rational r );
     
    56355952int ?>=?( Rational l, Rational r );
    56365953
    5637 // arithmetic
    5638 Rational -?( Rational r );
     5954Rational -?( Rational r );                              §\C{// arithmetic}§
    56395955Rational ?+?( Rational l, Rational r );
    56405956Rational ?-?( Rational l, Rational r );
     
    56425958Rational ?/?( Rational l, Rational r );
    56435959
    5644 // conversion
    5645 double widen( Rational r );
     5960double widen( Rational r );                             §\C{// conversion}§
    56465961Rational narrow( double f, long int md );
    56475962
    5648 // I/O
    5649 forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, Rational * );
     5963forall( dtype istype | istream( istype ) ) istype * ?|?( istype *, Rational * ); // I/O
    56505964forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, Rational );
    56515965\end{cfa}
Note: See TracChangeset for help on using the changeset viewer.