Changes in doc/user/user.tex [c6dc7f2:9e0a360]
- File:
-
- 1 edited
-
doc/user/user.tex (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/user/user.tex
rc6dc7f2 r9e0a360 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Sat Ju l 13 18:36:18201914 %% Update Count : 38 7613 %% Last Modified On : Sat Jun 15 16:29:45 2019 14 %% Update Count : 3847 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 2697 2697 \subsection{Expressions} 2698 2698 2699 % Change order of expression evaluation.2700 % http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0145r2.pdf2701 2702 2699 Multiple-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. 2703 2700 These notions are generalized to provide \CFA with \newterm{tuple expression}s and \newterm{tuple type}s. … … 3349 3346 3350 3347 3351 \section{ Stream I/OLibrary}3352 \label{s: StreamIOLibrary}3348 \section{I/O Stream Library} 3349 \label{s:IOStreamLibrary} 3353 3350 \index{input/output stream library} 3354 3351 \index{stream library} 3355 3352 3356 The goal of \CFA streaminput/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.3357 Stream I/O can be implicitly or explicitly formatted.3358 I mplicit formatting means \CFA selects the output or input format for values that match with the type of a variable.3359 Explicit 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.3361 Specifically: 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. 3362 3359 \begin{itemize} 3363 3360 \item 3364 ©printf© /Pythonformat codes are dense, making them difficult to read and remember.3361 ©printf© format codes are dense, making them difficult to read and remember. 3365 3362 \CFA/\CC format manipulators are named, making them easier to read and remember. 3366 3363 \item 3367 ©printf© /Pythonseparates format codes from associated variables, making it difficult to match codes with variables.3364 ©printf© separates format codes from associated variables, making it difficult to match codes with variables. 3368 3365 \CFA/\CC co-locate codes with associated variables, where \CFA has the tighter binding. 3369 3366 \item 3370 Format manipulators in \C FA have local effect, whereas \CC have global effect, except ©setw©.3367 Format manipulators in \CC have global rather than local effect, except ©setw©. 3371 3368 Hence, it is common programming practice to toggle manipulators on and then back to the default to prevent downstream side-effects. 3372 3369 Without this programming style, errors occur when moving prints, as manipulator effects incorrectly flow into the new location. 3373 3370 (To guarantee no side-effects, manipulator values must be saved and restored across function calls.) 3374 \item3375 \CFA has more sophisticated implicit spacing between values than Python, plus implicit newline at the end of a print.3376 3371 \end{itemize} 3377 3372 The \CFA header file for the I/O library is \Indexc{fstream.hfa}. 3378 3373 3379 For implicit formatted output, the common case is printing a seriesof variables separated by whitespace.3374 For unformatted output, the common case is printing a sequence of variables separated by whitespace. 3380 3375 \begin{cquote} 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}} \\3376 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 3377 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{\CC}} \\ 3383 3378 \begin{cfa} 3384 3379 int x = 1, y = 2, z = 3; … … 3390 3385 cout << x ®<< " "® << y ®<< " "® << z << endl; 3391 3386 \end{cfa} 3392 &3393 \begin{cfa}3394 x = 1; y = 2; z = 33395 print( x, y, z )3396 \end{cfa}3397 3387 \\ 3398 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt]3399 1® ®2® ®33400 \end{cfa}3401 &3402 3388 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] 3403 3389 1® ®2® ®3 … … 3443 3429 There 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. 3444 3430 3445 For implicit formattedinput, 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.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. 3446 3432 \begin{cquote} 3447 3433 \begin{lrbox}{\LstBox} … … 3450 3436 \end{cfa} 3451 3437 \end{lrbox} 3452 \begin{tabular}{@{}l@{\hspace{3em}}l@{ \hspace{3em}}l@{}}3438 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 3453 3439 \multicolumn{1}{@{}l@{}}{\usebox\LstBox} \\ 3454 \multicolumn{1}{c@{\hspace{ 2em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CC}} & \multicolumn{1}{c}{\textbf{Python}} \\3440 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{\CC}} \\ 3455 3441 \begin{cfa}[aboveskip=0pt,belowskip=0pt] 3456 3442 sin | x | y | z; … … 3460 3446 cin >> x >> y >> z; 3461 3447 \end{cfa} 3462 &3463 \begin{cfa}[aboveskip=0pt,belowskip=0pt]3464 x = int(input()); y = float(input()); z = input();3465 \end{cfa}3466 3448 \\ 3467 3449 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] 3468 3450 ®1® ®2.5® ®A® 3469 3470 3471 3451 \end{cfa} 3472 3452 & 3473 3453 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] 3474 3454 ®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®3483 3455 \end{cfa} 3484 3456 \end{tabular} … … 3509 3481 3510 3482 \item 3511 A separator does not appear before or after a null (empty) C string , which is a local mechanism to disable insertion of the separator character.3483 A separator does not appear before or after a null (empty) C string. 3512 3484 \begin{cfa} 3513 3485 sout | 1 | "" | 2 | "" | 3; 3514 3486 123 3515 3487 \end{cfa} 3488 which is a local mechanism to disable insertion of the separator character. 3516 3489 3517 3490 \item 3518 3491 {\lstset{language=CFA,deletedelim=**[is][]{¢}{¢}} 3519 A sep arator 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.3492 A seperator does not appear before a C string starting with the (extended) \Index*{ASCII}\index{ASCII!extended} characters: \lstinline[basicstyle=\tt]@,.;!?)]}%¢»@ 3520 3493 \begin{cfa}[belowskip=0pt] 3521 3494 sout | 1 | ", x" | 2 | ". x" | 3 | "; x" | 4 | "! x" | 5 | "? x" | 6 | "% x" … … 3525 3498 1®,® x 2®.® x 3®;® x 4®!® x 5®?® x 6®%® x 7§\color{red}\textcent§ x 8®»® x 9®)® x 10®]® x 11®}® x 3526 3499 \end{cfa}}% 3527 3528 \item 3529 A 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. 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]@([{=$£¥¡¿«@ 3530 3504 %$ 3531 3505 \begin{cfa}[mathescape=off] … … 3538 3512 \end{cfa} 3539 3513 %$ 3514 where \lstinline[basicstyle=\tt]@¡¿@ are inverted opening exclamation and question marks, and \lstinline[basicstyle=\tt]@«@ is an opening citation mark. 3540 3515 3541 3516 \item … … 3651 3626 The tuple separator also responses to being turned on and off. 3652 3627 \begin{cfa}[belowskip=0pt] 3653 sout | t1 | sepOff | t2; §\C{// turn off implicit separator for the next item}§3628 sout | t1 | sepOff | t2; §\C{// locally turn on/off implicit separator}§ 3654 3629 \end{cfa} 3655 3630 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3675 3650 \subsection{Newline Manipulators} 3676 3651 3677 The following \Index{manipulator s} control\Index{newline separation} for input and output.3652 The following \Index{manipulator} controls \Index{newline separation} for input and output. 3678 3653 3679 3654 For input: … … 3730 3705 0b0 0b11011 0b11011 0b11011 0b11011 3731 3706 sout | bin( -27HH ) | bin( -27H ) | bin( -27 ) | bin( -27L ); 3732 0b11100101 0b1111111111100101 0b11111111111111111111111111100101 0b ®(58 1s)®1001013707 0b11100101 0b1111111111100101 0b11111111111111111111111111100101 0b(58 1s)100101 3733 3708 \end{cfa} 3734 3709 … … 3773 3748 3774 3749 \item 3775 \Indexc{nobase}( integer )\index{manipulator!nobase@©nobase©} do not precede ©bin©, ©oct©, ©hex© with ©0b©/©0B©, ©0©, or ©0x©/©0X©. 3776 Printing the base is the default. 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. 3777 3751 \begin{cfa}[belowskip=0pt] 3778 3752 sout | nobase( bin( 27 ) ) | nobase( oct( 27 ) ) | nobase( hex( 27 ) ); … … 3808 3782 ® ®4.000000 ® ®4.000000 4.000000 3809 3783 ® ®ab ® ®ab ab 3784 ab ab ab 3810 3785 \end{cfa} 3811 3786 If the value is larger, it is printed without truncation, ignoring the ©minimum©.
Note:
See TracChangeset
for help on using the changeset viewer.