Changes in doc/user/user.tex [53a6c2a:86f384b]
- File:
-
- 1 edited
-
doc/user/user.tex (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/user/user.tex
r53a6c2a r86f384b 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Fri Jul 7 10:36:39201714 %% Update Count : 25 4713 %% Last Modified On : Sun Jul 2 09:49:56 2017 14 %% Update Count : 2503 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 2450 2450 \end{cfa} 2451 2451 \\ 2452 \begin{cfa}[ showspaces=true,aboveskip=0pt,belowskip=0pt]2452 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] 2453 2453 1® ®2® ®3 2454 2454 \end{cfa} 2455 2455 & 2456 \begin{cfa}[ showspaces=true,aboveskip=0pt,belowskip=0pt]2456 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] 2457 2457 1 2 3 2458 2458 \end{cfa} … … 2461 2461 The \CFA form has half the characters of the \CC form, and is similar to \Index*{Python} I/O with respect to implicit separators. 2462 2462 Similar 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 ] ]; 2465 2465 sout | t1 | t2 | endl; §\C{// print tuples}§ 2466 2466 \end{cfa} 2467 \begin{cfa}[ showspaces=true,aboveskip=0pt]2468 1®, ®2®, ®3 4®, ®5®, ®62467 \begin{cfa}[mathescape=off,showspaces=true,belowskip=0pt] 2468 1®, ®2®, ®3 3®, ®4®, ®5 2469 2469 \end{cfa} 2470 2470 Finally, \CFA uses the logical-or operator for I/O as it is the lowest-priority overloadable operator, other than assignment. … … 2485 2485 \\ 2486 2486 & 2487 \begin{cfa}[ showspaces=true,aboveskip=0pt]2487 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] 2488 2488 3 3 12 0 3 1 2 2489 2489 \end{cfa} … … 2503 2503 sout | 1 | 2 | 3 | endl; 2504 2504 \end{cfa} 2505 \begin{cfa}[ showspaces=true,aboveskip=0pt,belowskip=0pt]2505 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] 2506 2506 1 2 3 2507 2507 \end{cfa} … … 2570 2570 \subsection{Manipulator} 2571 2571 2572 The following \CC-style \Index{manipulator}s and routines control implicit seperation.2572 The following routines and \CC-style \Index{manipulator}s control implicit seperation. 2573 2573 \begin{enumerate} 2574 2574 \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.2575 Routines \Indexc{sepSet}\index{manipulator!sepSet@©sepSet©} and \Indexc{sepGet}\index{manipulator!sepGet@©sepGet©} set and get the separator string. 2576 2576 The 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] 2578 2578 sepSet( sout, ", $" ); §\C{// set separator from " " to ", \$"}§ 2579 sout | 1 | 2 | 3 | " \"" | ®sep ® | "\"" | endl;2579 sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl; 2580 2580 \end{cfa} 2581 2581 %$ … … 2584 2584 \end{cfa} 2585 2585 %$ 2586 \begin{cfa}[ belowskip=0pt]2586 \begin{cfa}[mathescape=off,aboveskip=0pt,belowskip=0pt] 2587 2587 sepSet( sout, " " ); §\C{// reset separator to " "}§ 2588 2588 sout | 1 | 2 | 3 | " \"" | ®sepGet( sout )® | "\"" | endl; 2589 2589 \end{cfa} 2590 \begin{cfa}[ showspaces=true,aboveskip=0pt]2590 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt] 2591 2591 1® ®2® ®3 ®" "® 2592 2592 \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 2595 Routine \Indexc{sepSetTuple}\index{manipulator!sepSetTuple@©sepSetTuple©} and \Indexc{sepGetTuple}\index{manipulator!sepGetTuple@©sepGetTuple©} get and set the tuple separator-string. 2613 2596 The 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] 2615 2598 sepSetTuple( sout, " " ); §\C{// set tuple separator from ", " to " "}§ 2616 sout | t1 | t2 | " \"" | ®sep Tuple® | "\"" | 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]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] 2622 2605 sepSetTuple( sout, ", " ); §\C{// reset tuple separator to ", "}§ 2623 2606 sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl; 2624 2607 \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] 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] 2636 2641 123 2637 2642 \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] 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}§ 2640 2651 \end{cfa} 2641 2652 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] 2642 2653 1 2 3 2643 2654 \end{cfa} 2644 2645 \item2646 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 32652 \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 232658 \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, 62665 \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 32673 \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}2680 2655 \end{enumerate} 2681 2656 2682 2657 \begin{comment} 2683 2658 #include <fstream> 2684 #include <string.h> // strcpy2685 2659 2686 2660 int main( void ) { 2687 2661 int x = 1, y = 2, z = 3; 2688 2662 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 ] ]; 2690 2664 sout | t1 | t2 | endl; // print tuples 2691 2665 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl; … … 2701 2675 2702 2676 sepSet( sout, ", $" ); // set separator from " " to ", $" 2703 sout | 1 | 2 | 3 | " \"" | sep | "\"" | endl;2677 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl; 2704 2678 sepSet( sout, " " ); // reset separator to " " 2705 2679 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl; 2706 2680 2707 char store[sepSize];2708 s trcpy( store, sepGet( sout ) );2709 sepSet( sout, "_" ); 2710 sout | 1 | 2 | 3 | endl;2711 s epSet( 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 2713 2687 2714 2688 sepSetTuple( sout, " " ); // set tuple separator from ", " to " " 2715 sout | t1 | t2 | " \"" | sep Tuple| "\"" | endl;2689 sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl; 2716 2690 sepSetTuple( sout, ", " ); // reset tuple separator to ", " 2717 2691 sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl; 2718 2692 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 2729 2695 } 2730 2696 … … 5582 5548 // C unsafe allocation 5583 5549 extern "C" { 5584 void * mall oc( size_t size );§\indexc{memset}§5550 void * mallac( size_t size );§\indexc{memset}§ 5585 5551 void * calloc( size_t dim, size_t size );§\indexc{calloc}§ 5586 5552 void * realloc( void * ptr, size_t size );§\indexc{realloc}§
Note:
See TracChangeset
for help on using the changeset viewer.