- Timestamp:
- Jul 7, 2017, 10:39:08 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 29038ef
- Parents:
- 52a9004
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/user/user.tex
r52a9004 r53a6c2a 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Sun Jul 2 09:49:56201714 %% Update Count : 25 0313 %% Last Modified On : Fri Jul 7 10:36:39 2017 14 %% Update Count : 2547 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 2450 2450 \end{cfa} 2451 2451 \\ 2452 \begin{cfa}[ mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]2452 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] 2453 2453 1® ®2® ®3 2454 2454 \end{cfa} 2455 2455 & 2456 \begin{cfa}[ mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]2456 \begin{cfa}[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} [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 ] ]; 2465 2465 sout | t1 | t2 | endl; §\C{// print tuples}§ 2466 2466 \end{cfa} 2467 \begin{cfa}[ mathescape=off,showspaces=true,belowskip=0pt]2468 1®, ®2®, ®3 3®, ®4®, ®52467 \begin{cfa}[showspaces=true,aboveskip=0pt] 2468 1®, ®2®, ®3 4®, ®5®, ®6 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}[ mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]2487 \begin{cfa}[showspaces=true,aboveskip=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}[ mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt]2505 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] 2506 2506 1 2 3 2507 2507 \end{cfa} … … 2570 2570 \subsection{Manipulator} 2571 2571 2572 The following routines and \CC-style \Index{manipulator}s control implicit seperation.2572 The following \CC-style \Index{manipulator}s and routines control implicit seperation. 2573 2573 \begin{enumerate} 2574 2574 \item 2575 Routines \Indexc{sepSet}\index{manipulator!sepSet@©sepSet©} and \Indexc{sep Get}\index{manipulator!sepGet@©sepGet©} set and get the separator string.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. 2576 2576 The 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] 2578 2578 sepSet( sout, ", $" ); §\C{// set separator from " " to ", \$"}§ 2579 sout | 1 | 2 | 3 | " \"" | ®sep Get( sout )® | "\"" | endl;2579 sout | 1 | 2 | 3 | " \"" | ®sep® | "\"" | endl; 2580 2580 \end{cfa} 2581 2581 %$ … … 2584 2584 \end{cfa} 2585 2585 %$ 2586 \begin{cfa}[ mathescape=off,aboveskip=0pt,belowskip=0pt]2586 \begin{cfa}[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}[ mathescape=off,showspaces=true,aboveskip=0pt]2590 \begin{cfa}[showspaces=true,aboveskip=0pt] 2591 2591 1® ®2® ®3 ®" "® 2592 2592 \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] 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. 2596 2613 The 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] 2598 2615 sepSetTuple( sout, " " ); §\C{// set tuple separator from ", " to " "}§ 2599 sout | t1 | t2 | " \"" | ®sep GetTuple( 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]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] 2605 2622 sepSetTuple( sout, ", " ); §\C{// reset tuple separator to ", "}§ 2606 2623 sout | t1 | t2 | " \"" | ®sepGetTuple( sout )® | "\"" | endl; 2607 2624 \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] 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] 2641 2636 123 2642 2637 \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] 2639 sout | sepEnable | 1 | 2 | 3 | endl; §\C{// globally turn on implicit separator}§ 2651 2640 \end{cfa} 2652 2641 \begin{cfa}[mathescape=off,showspaces=true,aboveskip=0pt,belowskip=0pt] 2653 2642 1 2 3 2654 2643 \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} 2655 2680 \end{enumerate} 2656 2681 2657 2682 \begin{comment} 2658 2683 #include <fstream> 2684 #include <string.h> // strcpy 2659 2685 2660 2686 int main( void ) { 2661 2687 int x = 1, y = 2, z = 3; 2662 2688 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 ] ]; 2664 2690 sout | t1 | t2 | endl; // print tuples 2665 2691 sout | x * 3 | y + 1 | z << 2 | x == y | (x | y) | (x || y) | (x > z ? 1 : 2) | endl; … … 2675 2701 2676 2702 sepSet( sout, ", $" ); // set separator from " " to ", $" 2677 sout | 1 | 2 | 3 | " \"" | sep Get( sout )| "\"" | endl;2703 sout | 1 | 2 | 3 | " \"" | sep | "\"" | endl; 2678 2704 sepSet( sout, " " ); // reset separator to " " 2679 2705 sout | 1 | 2 | 3 | " \"" | sepGet( sout ) | "\"" | endl; 2680 2706 2681 sout | sepOn | 1 | 2 | 3 | sepOn | endl; // separator at start of line2682 s out | 1 | sepOff | 2 | 3 | endl; // locally turn off implicit separator2683 2684 sout | sepDisable | 1 | 2 | 3 | endl; // globally turn off implicit separation2685 s out | 1 | sepOn | 2 | 3 | endl; // locally turn on implicit separator2686 sout | sepEnable | 1 | 2 | 3 | endl; // globally turn on implicit separation2707 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; 2687 2713 2688 2714 sepSetTuple( sout, " " ); // set tuple separator from ", " to " " 2689 sout | t1 | t2 | " \"" | sep GetTuple( sout )| "\"" | endl;2715 sout | t1 | t2 | " \"" | sepTuple | "\"" | endl; 2690 2716 sepSetTuple( sout, ", " ); // reset tuple separator to ", " 2691 2717 sout | t1 | t2 | " \"" | sepGetTuple( sout ) | "\"" | endl; 2692 2718 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 2695 2729 } 2696 2730 … … 5548 5582 // C unsafe allocation 5549 5583 extern "C" { 5550 void * mall ac( size_t size );§\indexc{memset}§5584 void * malloc( size_t size );§\indexc{memset}§ 5551 5585 void * calloc( size_t dim, size_t size );§\indexc{calloc}§ 5552 5586 void * realloc( void * ptr, size_t size );§\indexc{realloc}§
Note: See TracChangeset
for help on using the changeset viewer.