Changeset 53a6c2a for doc/user


Ignore:
Timestamp:
Jul 7, 2017, 10:39:08 AM (4 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:
29038ef
Parents:
52a9004
Message:

change meaning of sepOn, and replace #if with #pragma once in include files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    r52a9004 r53a6c2a  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Sun Jul  2 09:49:56 2017
    14 %% Update Count     : 2503
     13%% Last Modified On : Fri Jul  7 10:36:39 2017
     14%% Update Count     : 2547
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    24502450\end{cfa}
    24512451\\
    2452 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     2452\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    245324531® ®2® ®3
    24542454\end{cfa}
    24552455&
    2456 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     2456\begin{cfa}[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}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    2464 [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 3, [ 4, 5 ] ];
     2463\begin{cfa}
     2464[int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
    24652465sout | t1 | t2 | endl;                                  §\C{// print tuples}§
    24662466\end{cfa}
    2467 \begin{cfa}[mathescape=off,showspaces=true,belowskip=0pt]
    2468 1®, ®2®, ®3 3®, ®4®, ®5
     2467\begin{cfa}[showspaces=true,aboveskip=0pt]
     24681®, ®2®, ®3 4®, ®5®, ®6
    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}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     2487\begin{cfa}[showspaces=true,aboveskip=0pt]
    248824883 3 12 0 3 1 2
    24892489\end{cfa}
     
    25032503sout | 1 | 2 | 3 | endl;
    25042504\end{cfa}
    2505 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
     2505\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    250625061 2 3
    25072507\end{cfa}
     
    25702570\subsection{Manipulator}
    25712571
    2572 The following routines and \CC-style \Index{manipulator}s control implicit seperation.
     2572The following \CC-style \Index{manipulator}s and routines control implicit seperation.
    25732573\begin{enumerate}
    25742574\item
    2575 Routines \Indexc{sepSet}\index{manipulator!sepSet@©sepSet©} and \Indexc{sepGet}\index{manipulator!sepGet@©sepGet©} set and get the separator string.
     2575Routines \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.
    25762576The separator string can be at most 16 characters including the ©'\0'© string terminator (15 printable characters).
    2577 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2577\begin{cfa}[mathescape=off,belowskip=0pt]
    25782578sepSet( sout, ", $" );                                          §\C{// set separator from " " to ", \$"}§
    2579 sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;
     2579sout | 1 | 2 | 3 | " \"" | ®sep® | "\"" | endl;
    25802580\end{cfa}
    25812581%$
     
    25842584\end{cfa}
    25852585%$
    2586 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2586\begin{cfa}[belowskip=0pt]
    25872587sepSet( sout, " " );                                            §\C{// reset separator to " "}§
    25882588sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl;
    25892589\end{cfa}
    2590 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
     2590\begin{cfa}[showspaces=true,aboveskip=0pt]
    259125911® ®2® ®3 ®" "®
    25922592\end{cfa}
    2593 
    2594 \item
    2595 Routine \Indexc{sepSetTuple}\index{manipulator!sepSetTuple@©sepSetTuple©} and \Indexc{sepGetTuple}\index{manipulator!sepGetTuple@©sepGetTuple©} get and set the tuple separator-string.
     2593©sepGet© can be used to store a separator and then restore it:
     2594\begin{cfa}[belowskip=0pt]
     2595char store[®sepSize®];                                          §\C{// sepSize is the maximum separator size}§
     2596strcpy( store, sepGet( sout ) );
     2597sepSet( sout, "_" );
     2598sout | 1 | 2 | 3 | endl;
     2599\end{cfa}
     2600\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     26011®_®2®_®3
     2602\end{cfa}
     2603\begin{cfa}[belowskip=0pt]
     2604sepSet( sout, store );
     2605sout | 1 | 2 | 3 | endl;
     2606\end{cfa}
     2607\begin{cfa}[showspaces=true,aboveskip=0pt]
     26081® ®2® ®3
     2609\end{cfa}
     2610
     2611\item
     2612Routine \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.
    25962613The tuple separator-string can be at most 16 characters including the ©'\0'© string terminator (15 printable characters).
    2597 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2614\begin{cfa}[belowskip=0pt]
    25982615sepSetTuple( sout, " " );                                       §\C{// set tuple separator from ", " to " "}§
    2599 sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;
    2600 \end{cfa}
    2601 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
    2602 1 2 3 4 ®" "®
    2603 \end{cfa}
    2604 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
     2616sout | t1 | t2 | " \"" | ®sepTuple® | "\"" | endl;
     2617\end{cfa}
     2618\begin{cfa}[showspaces=true,aboveskip=0pt]
     26191 2 3 4 5 6 ®" "®
     2620\end{cfa}
     2621\begin{cfa}[belowskip=0pt]
    26052622sepSetTuple( sout, ", " );                                      §\C{// reset tuple separator to ", "}§
    26062623sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl;
    26072624\end{cfa}
    2608 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt]
    2609 1, 2, 3, 4 ®", "®
    2610 \end{cfa}
    2611 
    2612 \item
    2613 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.
    2614 \begin{cfa}[mathescape=off,belowskip=0pt]
    2615 sout | 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]
    2621 sout | 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]
    2624 12 3
    2625 \end{cfa}
    2626 The tuple separator also responses to being turned on and off.
    2627 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    2628 sout | 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}
    2633 Notice a tuple seperator starts the line because the next item is a tuple.
    2634 
    2635 \item
    2636 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, unless locally adjusted.
    2637 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    2638 sout | 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]
     2625\begin{cfa}[showspaces=true,aboveskip=0pt]
     26261, 2, 3 4, 5, 6 ®", "®
     2627\end{cfa}
     2628As for ©sepGet©, ©sepGetTuple© can be use to store a tuple separator and then restore it.
     2629
     2630\item
     2631Manipulators \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]
     2633sout | sepDisable | 1 | 2 | 3 | endl;           §\C{// globally turn off implicit separator}§
     2634\end{cfa}
     2635\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    26412636123
    26422637\end{cfa}
    2643 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    2644 sout | 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]
    2647 1® ®23
    2648 \end{cfa}
    2649 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt]
    2650 sout | sepEnable | 1 | 2 | 3 | endl;            §\C{// globally turn on implicit separation}§
     2638\begin{cfa}[belowskip=0pt]
     2639sout | sepEnable | 1 | 2 | 3 | endl;            §\C{// globally turn on implicit separator}§
    26512640\end{cfa}
    26522641\begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]
    265326421 2 3
    26542643\end{cfa}
     2644
     2645\item
     2646Manipulators \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]
     2648sout | 1 | sepOff | 2 | 3 | endl;                       §\C{// locally turn off implicit separator}§
     2649\end{cfa}
     2650\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     265112 3
     2652\end{cfa}
     2653\begin{cfa}[belowskip=0pt]
     2654sout | sepDisable | 1 | sepOn | 2 | 3 | endl; §\C{// locally turn on implicit separator}§
     2655\end{cfa}
     2656\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     26571 23
     2658\end{cfa}
     2659The tuple separator also responses to being turned on and off.
     2660\begin{cfa}[belowskip=0pt]
     2661sout | t1 | sepOff | t2 | endl;                         §\C{// locally turn on/off implicit separator}§
     2662\end{cfa}
     2663\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     26641, 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;
     2667use ©sep© to accomplish this functionality.
     2668\begin{cfa}[belowskip=0pt]
     2669sout | 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]
     26721 2 3
     2673\end{cfa}
     2674\begin{cfa}[belowskip=0pt]
     2675sout | 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}
    26552680\end{enumerate}
    26562681
    26572682\begin{comment}
    26582683#include <fstream>
     2684#include <string.h>                                                                             // strcpy
    26592685
    26602686int main( void ) {
    26612687        int x = 1, y = 2, z = 3;
    26622688        sout | x | y | z | endl;
    2663         [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 3, [ 4, 5 ] ];
     2689        [int, [ int, int ] ] t1 = [ 1, [ 2, 3 ] ], t2 = [ 4, [ 5, 6 ] ];
    26642690        sout | t1 | t2 | endl;                                          // print tuples
    26652691        sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl;
     
    26752701
    26762702        sepSet( sout, ", $" );                                          // set separator from " " to ", $"
    2677         sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
     2703        sout | 1 | 2 | 3 | " \"" | sep | "\"" | endl;
    26782704        sepSet( sout, " " );                                            // reset separator to " "
    26792705        sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl;
    26802706
    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
     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;
    26872713
    26882714        sepSetTuple( sout, " " );                                       // set tuple separator from ", " to " "
    2689         sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
     2715        sout | t1 | t2 | " \"" | sepTuple | "\"" | endl;
    26902716        sepSetTuple( sout, ", " );                                      // reset tuple separator to ", "
    26912717        sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl;
    26922718
    2693         sout | t1 | t2 | endl;                                          // print tuple
    2694         sout | sepOn | t1 | sepOff | t2 | endl;         // locally turn on/off implicit separation
     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
    26952729}
    26962730
     
    55485582// C unsafe allocation
    55495583extern "C" {
    5550 void * mallac( size_t size );§\indexc{memset}§
     5584void * malloc( size_t size );§\indexc{memset}§
    55515585void * calloc( size_t dim, size_t size );§\indexc{calloc}§
    55525586void * realloc( void * ptr, size_t size );§\indexc{realloc}§
Note: See TracChangeset for help on using the changeset viewer.