Changeset f53acdf8 for doc/user/user.tex
- Timestamp:
- Jul 19, 2019, 2:16:01 PM (6 years ago)
- 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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/user/user.tex
r1f1c102 rf53acdf8 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 n 15 16:29:45201914 %% Update Count : 38 4713 %% Last Modified On : Sat Jul 13 18:36:18 2019 14 %% Update Count : 3876 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.pdf 2701 2699 2702 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. 2700 2703 These notions are generalized to provide \CFA with \newterm{tuple expression}s and \newterm{tuple type}s. … … 3346 3349 3347 3350 3348 \section{ I/O StreamLibrary}3349 \label{s: IOStreamLibrary}3351 \section{Stream I/O Library} 3352 \label{s:StreamIOLibrary} 3350 3353 \index{input/output stream library} 3351 3354 \index{stream library} 3352 3355 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. 3356 The 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. 3357 Stream I/O can be implicitly or explicitly formatted. 3358 Implicit 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: 3359 3362 \begin{itemize} 3360 3363 \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. 3362 3365 \CFA/\CC format manipulators are named, making them easier to read and remember. 3363 3366 \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. 3365 3368 \CFA/\CC co-locate codes with associated variables, where \CFA has the tighter binding. 3366 3369 \item 3367 Format manipulators in \C C have global rather than local effect, except ©setw©.3370 Format manipulators in \CFA have local effect, whereas \CC have global effect, except ©setw©. 3368 3371 Hence, it is common programming practice to toggle manipulators on and then back to the default to prevent downstream side-effects. 3369 3372 Without this programming style, errors occur when moving prints, as manipulator effects incorrectly flow into the new location. 3370 3373 (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. 3371 3376 \end{itemize} 3372 3377 The \CFA header file for the I/O library is \Indexc{fstream.hfa}. 3373 3378 3374 For unformatted output, the common case is printing a sequenceof variables separated by whitespace.3379 For implicit formatted output, the common case is printing a series of variables separated by whitespace. 3375 3380 \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}} \\ 3378 3383 \begin{cfa} 3379 3384 int x = 1, y = 2, z = 3; … … 3385 3390 cout << x ®<< " "® << y ®<< " "® << z << endl; 3386 3391 \end{cfa} 3392 & 3393 \begin{cfa} 3394 x = 1; y = 2; z = 3 3395 print( x, y, z ) 3396 \end{cfa} 3387 3397 \\ 3398 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] 3399 1® ®2® ®3 3400 \end{cfa} 3401 & 3388 3402 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] 3389 3403 1® ®2® ®3 … … 3429 3443 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. 3430 3444 3431 For unformatterinput, 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.3445 For 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. 3432 3446 \begin{cquote} 3433 3447 \begin{lrbox}{\LstBox} … … 3436 3450 \end{cfa} 3437 3451 \end{lrbox} 3438 \begin{tabular}{@{}l@{\hspace{3em}}l@{ }}3452 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{3em}}l@{}} 3439 3453 \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}} \\ 3441 3455 \begin{cfa}[aboveskip=0pt,belowskip=0pt] 3442 3456 sin | x | y | z; … … 3446 3460 cin >> x >> y >> z; 3447 3461 \end{cfa} 3462 & 3463 \begin{cfa}[aboveskip=0pt,belowskip=0pt] 3464 x = int(input()); y = float(input()); z = input(); 3465 \end{cfa} 3448 3466 \\ 3449 3467 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] 3450 3468 ®1® ®2.5® ®A® 3469 3470 3451 3471 \end{cfa} 3452 3472 & 3453 3473 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] 3454 3474 ®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® 3455 3483 \end{cfa} 3456 3484 \end{tabular} … … 3481 3509 3482 3510 \item 3483 A separator does not appear before or after a null (empty) C string .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. 3484 3512 \begin{cfa} 3485 3513 sout | 1 | "" | 2 | "" | 3; 3486 3514 123 3487 3515 \end{cfa} 3488 which is a local mechanism to disable insertion of the separator character.3489 3516 3490 3517 \item 3491 3518 {\lstset{language=CFA,deletedelim=**[is][]{¢}{¢}} 3492 A sep erator does not appear before a C string starting with the (extended) \Index*{ASCII}\index{ASCII!extended} characters: \lstinline[basicstyle=\tt]@,.;!?)]}%¢»@3519 A 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. 3493 3520 \begin{cfa}[belowskip=0pt] 3494 3521 sout | 1 | ", x" | 2 | ". x" | 3 | "; x" | 4 | "! x" | 5 | "? x" | 6 | "% x" … … 3498 3525 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 3499 3526 \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 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. 3504 3530 %$ 3505 3531 \begin{cfa}[mathescape=off] … … 3512 3538 \end{cfa} 3513 3539 %$ 3514 where \lstinline[basicstyle=\tt]@¡¿@ are inverted opening exclamation and question marks, and \lstinline[basicstyle=\tt]@«@ is an opening citation mark.3515 3540 3516 3541 \item … … 3626 3651 The tuple separator also responses to being turned on and off. 3627 3652 \begin{cfa}[belowskip=0pt] 3628 sout | t1 | sepOff | t2; §\C{// locally turn on/off implicit separator}§3653 sout | t1 | sepOff | t2; §\C{// turn off implicit separator for the next item}§ 3629 3654 \end{cfa} 3630 3655 \begin{cfa}[showspaces=true,aboveskip=0pt,belowskip=0pt] … … 3650 3675 \subsection{Newline Manipulators} 3651 3676 3652 The following \Index{manipulator } controls\Index{newline separation} for input and output.3677 The following \Index{manipulators} control \Index{newline separation} for input and output. 3653 3678 3654 3679 For input: … … 3705 3730 0b0 0b11011 0b11011 0b11011 0b11011 3706 3731 sout | bin( -27HH ) | bin( -27H ) | bin( -27 ) | bin( -27L ); 3707 0b11100101 0b1111111111100101 0b11111111111111111111111111100101 0b (58 1s)1001013732 0b11100101 0b1111111111100101 0b11111111111111111111111111100101 0b®(58 1s)®100101 3708 3733 \end{cfa} 3709 3734 … … 3748 3773 3749 3774 \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©. 3776 Printing the base is the default. 3751 3777 \begin{cfa}[belowskip=0pt] 3752 3778 sout | nobase( bin( 27 ) ) | nobase( oct( 27 ) ) | nobase( hex( 27 ) ); … … 3782 3808 ® ®4.000000 ® ®4.000000 4.000000 3783 3809 ® ®ab ® ®ab ab 3784 ab ab ab3785 3810 \end{cfa} 3786 3811 If the value is larger, it is printed without truncation, ignoring the ©minimum©.
Note:
See TracChangeset
for help on using the changeset viewer.