Changeset f53acdf8 for doc/user/user.tex


Ignore:
Timestamp:
Jul 19, 2019, 2:16:01 PM (6 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
4eb43fa
Parents:
1f1c102 (diff), 8ac3b0e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into new-ast

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/user/user.tex

    r1f1c102 rf53acdf8  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Sat Jun 15 16:29:45 2019
    14 %% Update Count     : 3847
     13%% Last Modified On : Sat Jul 13 18:36:18 2019
     14%% Update Count     : 3876
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    26972697\subsection{Expressions}
    26982698
     2699% Change order of expression evaluation.
     2700% http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0145r2.pdf
     2701
    26992702Multiple-return-value functions provide \CFA with a new syntax for expressing a combination of expressions in the return statement and a combination of types in a function signature.
    27002703These notions are generalized to provide \CFA with \newterm{tuple expression}s and \newterm{tuple type}s.
     
    33463349
    33473350
    3348 \section{I/O Stream Library}
    3349 \label{s:IOStreamLibrary}
     3351\section{Stream I/O Library}
     3352\label{s:StreamIOLibrary}
    33503353\index{input/output stream library}
    33513354\index{stream library}
    33523355
    3353 The goal of \CFA input/output (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.
    3354 \CFA I/O combines ideas from C ©printf©, \CC, and Python.
    3355 I/O can be unformatted or formatted.
    3356 Unformatted means \CFA selects the output or input format for values that match with the type of a variable.
    3357 Formatted means additional information is specified to augment how an output or input of value is interpreted.
    3358 \CFA formatting is a cross between C ©printf© and \CC ©cout© manipulators.
     3356The goal of \CFA stream input/output (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.
     3357Stream I/O can be implicitly or explicitly formatted.
     3358Implicit formatting means \CFA selects the output or input format for values that match with the type of a variable.
     3359Explicit formatting means additional information is specified to augment how an output or input of value is interpreted.
     3360\CFA formatting is a cross between C ©printf© and \CC ©cout© manipulators, and Python implicit spacing and newline.
     3361Specifically:
    33593362\begin{itemize}
    33603363\item
    3361 ©printf© format codes are dense, making them difficult to read and remember.
     3364©printf©/Python format codes are dense, making them difficult to read and remember.
    33623365\CFA/\CC format manipulators are named, making them easier to read and remember.
    33633366\item
    3364 ©printf© separates format codes from associated variables, making it difficult to match codes with variables.
     3367©printf©/Python separates format codes from associated variables, making it difficult to match codes with variables.
    33653368\CFA/\CC co-locate codes with associated variables, where \CFA has the tighter binding.
    33663369\item
    3367 Format manipulators in \CC have global rather than local effect, except ©setw©.
     3370Format manipulators in \CFA have local effect, whereas \CC have global effect, except ©setw©.
    33683371Hence, it is common programming practice to toggle manipulators on and then back to the default to prevent downstream side-effects.
    33693372Without this programming style, errors occur when moving prints, as manipulator effects incorrectly flow into the new location.
    33703373(To guarantee no side-effects, manipulator values must be saved and restored across function calls.)
     3374\item
     3375\CFA has more sophisticated implicit spacing between values than Python, plus implicit newline at the end of a print.
    33713376\end{itemize}
    33723377The \CFA header file for the I/O library is \Indexc{fstream.hfa}.
    33733378
    3374 For unformatted output, the common case is printing a sequence of variables separated by whitespace.
     3379For implicit formatted output, the common case is printing a series of variables separated by whitespace.
    33753380\begin{cquote}
    3376 \begin{tabular}{@{}l@{\hspace{3em}}l@{}}
    3377 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c}{\textbf{\CC}}      \\
     3381\begin{tabular}{@{}l@{\hspace{2em}}l@{\hspace{2em}}l@{}}
     3382\multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}}        & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CC}}       & \multicolumn{1}{c}{\textbf{Python}}   \\
    33783383\begin{cfa}
    33793384int x = 1, y = 2, z = 3;
     
    33853390cout << x ®<< " "® << y ®<< " "® << z << endl;
    33863391\end{cfa}
     3392&
     3393\begin{cfa}
     3394x = 1;  y = 2;  z = 3
     3395print( x, y, z )
     3396\end{cfa}
    33873397\\
     3398\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     33991® ®2® ®3
     3400\end{cfa}
     3401&
    33883402\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    338934031® ®2® ®3
     
    34293443There is a weak similarity between the \CFA logical-or operator and the \Index{Shell pipe-operator} for moving data, where data flows in the correct direction for input but the opposite direction for output.
    34303444
    3431 For unformatter input, the common case is reading a sequence of values separated by whitespace, where the type of an input constant must match with the type of the input variable.
     3445For implicit formatted input, the common case is reading a sequence of values separated by whitespace, where the type of an input constant must match with the type of the input variable.
    34323446\begin{cquote}
    34333447\begin{lrbox}{\LstBox}
     
    34363450\end{cfa}
    34373451\end{lrbox}
    3438 \begin{tabular}{@{}l@{\hspace{3em}}l@{}}
     3452\begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{3em}}l@{}}
    34393453\multicolumn{1}{@{}l@{}}{\usebox\LstBox} \\
    3440 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}}        & \multicolumn{1}{c}{\textbf{\CC}}      \\
     3454\multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}}        & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CC}}       & \multicolumn{1}{c}{\textbf{Python}}   \\
    34413455\begin{cfa}[aboveskip=0pt,belowskip=0pt]
    34423456sin | x | y | z;
     
    34463460cin >> x >> y >> z;
    34473461\end{cfa}
     3462&
     3463\begin{cfa}[aboveskip=0pt,belowskip=0pt]
     3464x = int(input());  y = float(input());  z = input();
     3465\end{cfa}
    34483466\\
    34493467\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    34503468®1® ®2.5® ®A®
     3469
     3470
    34513471\end{cfa}
    34523472&
    34533473\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
    34543474®1® ®2.5® ®A®
     3475
     3476
     3477\end{cfa}
     3478&
     3479\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     3480®1®
     3481®2.5®
     3482®A®
    34553483\end{cfa}
    34563484\end{tabular}
     
    34813509
    34823510\item
    3483 A separator does not appear before or after a null (empty) C string.
     3511A separator does not appear before or after a null (empty) C string, which is a local mechanism to disable insertion of the separator character.
    34843512\begin{cfa}
    34853513sout | 1 | "" | 2 | "" | 3;
    34863514123
    34873515\end{cfa}
    3488 which is a local mechanism to disable insertion of the separator character.
    34893516
    34903517\item
    34913518{\lstset{language=CFA,deletedelim=**[is][]{¢}{¢}}
    3492 A seperator does not appear before a C string starting with the (extended) \Index*{ASCII}\index{ASCII!extended} characters: \lstinline[basicstyle=\tt]@,.;!?)]}%¢»@
     3519A separator does not appear before a C string starting with the (extended) \Index*{ASCII}\index{ASCII!extended} characters: \lstinline[basicstyle=\tt]@,.;!?)]}%¢»@, where \lstinline[basicstyle=\tt]@»@ is a closing citation mark.
    34933520\begin{cfa}[belowskip=0pt]
    34943521sout | 1 | ", x" | 2 | ". x" | 3 | "; x" | 4 | "! x" | 5 | "? x" | 6 | "% x"
     
    349835251®,® x 2®.® x 3®;® x 4®!® x 5®?® x 6®%® x 7§\color{red}\textcent§ x 8®»® x 9®)® x 10®]® x 11®}® x
    34993526\end{cfa}}%
    3500 where \lstinline[basicstyle=\tt]@»@ is a closing citation mark.
    3501 
    3502 \item
    3503 A separator does not appear after a C string ending with the (extended) \Index*{ASCII}\index{ASCII!extended} characters: \lstinline[mathescape=off,basicstyle=\tt]@([{=$£¥¡¿«@
     3527
     3528\item
     3529A separator does not appear after a C string ending with the (extended) \Index*{ASCII}\index{ASCII!extended} characters: \lstinline[mathescape=off,basicstyle=\tt]@([{=$£¥¡¿«@, where \lstinline[basicstyle=\tt]@¡¿@ are inverted opening exclamation and question marks, and \lstinline[basicstyle=\tt]@«@ is an opening citation mark.
    35043530%$
    35053531\begin{cfa}[mathescape=off]
     
    35123538\end{cfa}
    35133539%$
    3514 where \lstinline[basicstyle=\tt]@¡¿@ are inverted opening exclamation and question marks, and \lstinline[basicstyle=\tt]@«@ is an opening citation mark.
    35153540
    35163541\item
     
    36263651The tuple separator also responses to being turned on and off.
    36273652\begin{cfa}[belowskip=0pt]
    3628 sout | t1 | sepOff | t2; §\C{// locally turn on/off implicit separator
     3653sout | t1 | sepOff | t2; §\C{// turn off implicit separator for the next item
    36293654\end{cfa}
    36303655\begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]
     
    36503675\subsection{Newline Manipulators}
    36513676
    3652 The following \Index{manipulator} controls \Index{newline separation} for input and output.
     3677The following \Index{manipulators} control \Index{newline separation} for input and output.
    36533678
    36543679For input:
     
    370537300b0 0b11011 0b11011 0b11011 0b11011
    37063731sout | bin( -27HH ) | bin( -27H ) | bin( -27 ) | bin( -27L );
    3707 0b11100101 0b1111111111100101 0b11111111111111111111111111100101 0b(58 1s)100101
     37320b11100101 0b1111111111100101 0b11111111111111111111111111100101 0b®(58 1s)®100101
    37083733\end{cfa}
    37093734
     
    37483773
    37493774\item
    3750 \Indexc{nobase}( integer )\index{manipulator!nobase@©nobase©} do not precede ©bin©, ©oct©, ©hex© with ©0b©/©0B©, ©0©, or ©0x©/©0X©. Printing the base is the default.
     3775\Indexc{nobase}( integer )\index{manipulator!nobase@©nobase©} do not precede ©bin©, ©oct©, ©hex© with ©0b©/©0B©, ©0©, or ©0x©/©0X©.
     3776Printing the base is the default.
    37513777\begin{cfa}[belowskip=0pt]
    37523778sout | nobase( bin( 27 ) ) | nobase( oct( 27 ) ) | nobase( hex( 27 ) );
     
    37823808®  ®4.000000 ® ®4.000000 4.000000
    37833809®  ®ab ® ®ab ab
    3784     ab    ab ab
    37853810\end{cfa}
    37863811If the value is larger, it is printed without truncation, ignoring the ©minimum©.
Note: See TracChangeset for help on using the changeset viewer.