Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    r53a6c2a r86f384b  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Fri Jul  7 10:36:39 2017
    14 %% Update Count     : 2547
     13%% Last Modified On : Sun Jul  2 09:49:56 2017
     14%% Update Count     : 2503
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    24502450\end{cfa}
    24512451\\
    2452 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     2452\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    245324531® ®2® ®3
    24542454\end{cfa}
    24552455&
    2456 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     2456\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    245724571 2 3
    24582458\end{cfa}
     
    24612461The \CFA form has half the characters of the \CC form, and is similar to \Index*{Python} I/O with respect to implicit separators.
    24622462Similar simplification occurs for \Index{tuple} I/O, which prints all tuple values separated by ``\lstinline[showspaces=true]@, @''.
    2463 \begin{cfa}
    2464 [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
     2463\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2464[int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 3, [ 4, 5 ] ];
    24652465sout | t1 | t2 | endl;                                  §\C{// print tuples}§
    24662466\end{cfa}
    2467 \begin{cfa}[showspaces=true,aboveskip=0pt]
    2468 1®, ®2®, ®3 4®, ®5®, ®6
     2467\begin{cfa}[mathescape=off,showspaces=true,belowskip=0pt]
     24681®, ®2®, ®3 3®, ®4®, ®5
    24692469\end{cfa}
    24702470Finally, \CFA uses the logical-or operator for I/O as it is the lowest-priority overloadable operator, other than assignment.
     
    24852485\\
    24862486&
    2487 \begin{cfa}[showspaces=true,aboveskip=0pt]
     2487\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    248824883 3 12 0 3 1 2
    24892489\end{cfa}
     
    25032503sout | 1 | 2 | 3 | endl;
    25042504\end{cfa}
    2505 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     2505\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    250625061 2 3
    25072507\end{cfa}
     
    25702570\subsection{Manipulator}
    25712571
    2572 The following \CC-style \Index{manipulator}s and routines control implicit seperation.
     2572The following routines and \CC-style \Index{manipulator}s control implicit seperation.
    25732573\begin{enumerate}
    25742574\item
    2575 Routines \Indexc{sepSet}\index{manipulator!sepSet@©sepSet©} and \Indexc{sep}\index{manipulator!sep@©sep©}/\Indexc{sepGet}\index{manipulator!sepGet@©sepGet©} set and get the separator string.
     2575Routines \Indexc{sepSet}\index{manipulator!sepSet@©sepSet©} and \Indexc{sepGet}\index{manipulator!sepGet@©sepGet©} set and get the separator string.
    25762576The separator string can be at most 16 characters including the ©'\0'© string terminator (15 printable characters).
    2577 \begin{cfa}[mathescape=off,belowskip=0pt]
     2577\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    25782578sepSet( sout, ", $" );                                          §\C{// set separator from " " to ", \$"}§
    2579 sout | 1 | 2 | 3 | " \"" | ®sep® | "\"" | endl;
     2579sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;
    25802580\end{cfa}
    25812581%$
     
    25842584\end{cfa}
    25852585%$
    2586 \begin{cfa}[belowskip=0pt]
     2586\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    25872587sepSet( sout, " " );                                            §\C{// reset separator to " "}§
    25882588sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;
    25892589\end{cfa}
    2590 \begin{cfa}[showspaces=true,aboveskip=0pt]
     2590\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
    259125911® ®2® ®3 ®" "®
    25922592\end{cfa}
    2593 ©sepGet© can be used to store a separator and then restore it:
    2594 \begin{cfa}[belowskip=0pt]
    2595 char store[®sepSize®];                                          §\C{// sepSize is the maximum separator size}§
    2596 strcpy( store, sepGet( sout ) );
    2597 sepSet( sout, "_" );
    2598 sout | 1 | 2 | 3 | endl;
    2599 \end{cfa}
    2600 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    2601 1®_®2®_®3
    2602 \end{cfa}
    2603 \begin{cfa}[belowskip=0pt]
    2604 sepSet( sout, store );
    2605 sout | 1 | 2 | 3 | endl;
    2606 \end{cfa}
    2607 \begin{cfa}[showspaces=true,aboveskip=0pt]
    2608 1® ®2® ®3
    2609 \end{cfa}
    2610 
    2611 \item
    2612 Routine \Indexc{sepSetTuple}\index{manipulator!sepSetTuple@©sepSetTuple©} and \Indexc{sepTuple}\index{manipulator!sepTuple@©sepTuple©}/\Indexc{sepGetTuple}\index{manipulator!sepGetTuple@©sepGetTuple©} get and set the tuple separator-string.
     2593
     2594\item
     2595Routine \Indexc{sepSetTuple}\index{manipulator!sepSetTuple@©sepSetTuple©} and \Indexc{sepGetTuple}\index{manipulator!sepGetTuple@©sepGetTuple©} get and set the tuple separator-string.
    26132596The tuple separator-string can be at most 16 characters including the ©'\0'© string terminator (15 printable characters).
    2614 \begin{cfa}[belowskip=0pt]
     2597\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    26152598sepSetTuple( sout, " " );                                       §\C{// set tuple separator from ", " to " "}§
    2616 sout | t1 | t2 | " \"" | ®sepTuple® | "\"" | endl;
    2617 \end{cfa}
    2618 \begin{cfa}[showspaces=true,aboveskip=0pt]
    2619 1 2 3 4 5 6 ®" "®
    2620 \end{cfa}
    2621 \begin{cfa}[belowskip=0pt]
     2599sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;
     2600\end{cfa}
     2601\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     26021 2 3 4 ®" "®
     2603\end{cfa}
     2604\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    26222605sepSetTuple( sout, ", " );                                      §\C{// reset tuple separator to ", "}§
    26232606sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;
    26242607\end{cfa}
    2625 \begin{cfa}[showspaces=true,aboveskip=0pt]
    2626 1, 2, 3 4, 5, 6 ®", "®
    2627 \end{cfa}
    2628 As for ©sepGet©, ©sepGetTuple© can be use to store a tuple separator and then restore it.
    2629 
    2630 \item
    2631 Manipulators \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.
    2632 \begin{cfa}[belowskip=0pt]
    2633 sout | sepDisable | 1 | 2 | 3 | endl;           §\C{// globally turn off implicit separator}§
    2634 \end{cfa}
    2635 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     2608\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     26091, 2, 3, 4 ®", "®
     2610\end{cfa}
     2611
     2612\item
     2613Manipulators \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.
     2614\begin{cfa}[mathescape=off,belowskip=0pt]
     2615sout | sepOn | 1 | 2 | 3 | sepOn | endl;        §\C{// separator at start/end of line}§
     2616\end{cfa}
     2617\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     2618® ®1 2 3® ®
     2619\end{cfa}
     2620\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2621sout | 1 | sepOff | 2 | 3 | endl;                       §\C{// locally turn off implicit separator}§
     2622\end{cfa}
     2623\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     262412 3
     2625\end{cfa}
     2626The tuple separator also responses to being turned on and off.
     2627\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2628sout | sepOn | t1 | sepOff | t2 | endl;         §\C{// locally turn on/off implicit separation}§
     2629\end{cfa}
     2630\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     2631, 1, 23, 4
     2632\end{cfa}
     2633Notice a tuple seperator starts the line because the next item is a tuple.
     2634
     2635\item
     2636Manipulators \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.
     2637\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2638sout | sepDisable | 1 | 2 | 3 | endl;           §\C{// globally turn off implicit separation}§
     2639\end{cfa}
     2640\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    26362641123
    26372642\end{cfa}
    2638 \begin{cfa}[belowskip=0pt]
    2639 sout | sepEnable | 1 | 2 | 3 | endl;            §\C{// globally turn on implicit separator}§
     2643\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2644sout | 1 | ®sepOn® | 2 | 3 | endl;                      §\C{// locally turn on implicit separator}§
     2645\end{cfa}
     2646\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     26471® ®23
     2648\end{cfa}
     2649\begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2650sout | sepEnable | 1 | 2 | 3 | endl;            §\C{// globally turn on implicit separation}§
    26402651\end{cfa}
    26412652\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    264226531 2 3
    26432654\end{cfa}
    2644 
    2645 \item
    2646 Manipulators \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.
    2647 \begin{cfa}[belowskip=0pt]
    2648 sout | 1 | sepOff | 2 | 3 | endl;                       §\C{// locally turn off implicit separator}§
    2649 \end{cfa}
    2650 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    2651 12 3
    2652 \end{cfa}
    2653 \begin{cfa}[belowskip=0pt]
    2654 sout | sepDisable | 1 | sepOn | 2 | 3 | endl; §\C{// locally turn on implicit separator}§
    2655 \end{cfa}
    2656 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    2657 1 23
    2658 \end{cfa}
    2659 The tuple separator also responses to being turned on and off.
    2660 \begin{cfa}[belowskip=0pt]
    2661 sout | t1 | sepOff | t2 | endl;                         §\C{// locally turn on/off implicit separator}§
    2662 \end{cfa}
    2663 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    2664 1, 2, 34, 5, 6
    2665 \end{cfa}
    2666 ©sepOn© \emph{cannot} be used to start/end a line with a separator because separators do not appear at the start/end of a line;
    2667 use ©sep© to accomplish this functionality.
    2668 \begin{cfa}[belowskip=0pt]
    2669 sout | sepOn | 1 | 2 | 3 | sepOn | endl ;       §\C{// sepOn does nothing at start/end of line}§
    2670 \end{cfa}
    2671 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    2672 1 2 3
    2673 \end{cfa}
    2674 \begin{cfa}[belowskip=0pt]
    2675 sout | sep | 1 | 2 | 3 | sep | endl ;           §\C{// use sep to print separator at start/end of line}§
    2676 \end{cfa}
    2677 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    2678 ® ®1 2 3® ®
    2679 \end{cfa}
    26802655\end{enumerate}
    26812656
    26822657\begin{comment}
    26832658#include <fstream>
    2684 #include <string.h>                                                                             // strcpy
    26852659
    26862660int main( void ) {
    26872661        int x = 1, y = 2, z = 3;
    26882662        sout | x | y | z | endl;
    2689         [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
     2663        [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 3, [ 4, 5 ] ];
    26902664        sout | t1 | t2 | endl;                                          // print tuples
    26912665        sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;
     
    27012675
    27022676        sepSet( sout, ", $" );                                          // set separator from " " to ", $"
    2703         sout | 1 | 2 | 3 | " \"" | sep | "\"" | endl;
     2677        sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    27042678        sepSet( sout, " " );                                            // reset separator to " "
    27052679        sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    27062680
    2707         char store[sepSize];
    2708         strcpy( store, sepGet( sout ) );
    2709         sepSet( sout, "_" );
    2710         sout | 1 | 2 | 3 | endl;
    2711         sepSet( sout, store );
    2712         sout | 1 | 2 | 3 | endl;
     2681        sout | sepOn | 1 | 2 | 3 | sepOn | endl;        // separator at start of line
     2682        sout | 1 | sepOff | 2 | 3 | endl;                       // locally turn off implicit separator
     2683
     2684        sout | sepDisable | 1 | 2 | 3 | endl;           // globally turn off implicit separation
     2685        sout | 1 | sepOn | 2 | 3 | endl;                        // locally turn on implicit separator
     2686        sout | sepEnable | 1 | 2 | 3 | endl;            // globally turn on implicit separation
    27132687
    27142688        sepSetTuple( sout, " " );                                       // set tuple separator from ", " to " "
    2715         sout | t1 | t2 | " \"" | sepTuple | "\"" | endl;
     2689        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
    27162690        sepSetTuple( sout, ", " );                                      // reset tuple separator to ", "
    27172691        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
    27182692
    2719         sout | sepDisable | 1 | 2 | 3 | endl;           // globally turn off implicit separator
    2720         sout | sepEnable | 1 | 2 | 3 | endl;            // globally turn on implicit separator
    2721        
    2722         sout | 1 | sepOff | 2 | 3 | endl;                       // locally turn on implicit separator
    2723         sout | sepDisable | 1 | sepOn | 2 | 3 | endl; // globally turn off implicit separator
    2724         sout | sepEnable;
    2725         sout | t1 | sepOff | t2 | endl;                         // locally turn on/off implicit separator
    2726 
    2727         sout | sepOn | 1 | 2 | 3 | sepOn | endl ;       // sepOn does nothing at start/end of line
    2728         sout | sep | 1 | 2 | 3 | sep | endl ;           // use sep to print separator at start/end of line
     2693        sout | t1 | t2 | endl;                                          // print tuple
     2694        sout | sepOn | t1 | sepOff | t2 | endl;         // locally turn on/off implicit separation
    27292695}
    27302696
     
    55825548// C unsafe allocation
    55835549extern "C" {
    5584 void * malloc( size_t size );§\indexc{memset}§
     5550void * mallac( size_t size );§\indexc{memset}§
    55855551void * calloc( size_t dim, size_t size );§\indexc{calloc}§
    55865552void * realloc( void * ptr, size_t size );§\indexc{realloc}§
Note: See TracChangeset for help on using the changeset viewer.