Changes in / [8514bcf8:cfcbd03]
- Location:
- doc
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/LaTeXmacros/common.sty
r8514bcf8 rcfcbd03 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Sun Jul 16 08:28:52202314 %% Update Count : 58 613 %% Last Modified On : Fri Sep 29 16:48:59 2023 14 %% Update Count : 587 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 272 272 \setlength{\gcolumnposn}{2.75in} 273 273 \setlength{\columnposn}{\gcolumnposn} 274 \newcommand{\setgcolumn}[1]{\global\gcolumnposn=#1\global\columnposn=\gcolumnposn} 274 275 \newcommand{\C}[2][\@empty]{\ifx#1\@empty\else\global\setlength{\columnposn}{#1}\global\columnposn=\columnposn\fi\hfill\makebox[\textwidth-\columnposn][l]{\lst@basicstyle{\LstCommentStyle{#2}}}} 275 276 \newcommand{\CRT}{\global\columnposn=\gcolumnposn} … … 302 303 literate= 303 304 {-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.75ex}{0.1ex}}}}1 304 {^}{\raisebox{0.6ex}{$\scripts criptstyle\land\,$}}1305 {^}{\raisebox{0.6ex}{$\scriptstyle\land\,$}}1 305 306 {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 306 307 {`}{\ttfamily\upshape\hspace*{-0.3ex}`}1 -
doc/LaTeXmacros/common.tex
r8514bcf8 rcfcbd03 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Fri Jul 21 09:02:00202314 %% Update Count : 5 7613 %% Last Modified On : Fri Sep 29 16:49:02 2023 14 %% Update Count : 590 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 275 275 \setlength{\gcolumnposn}{2.75in} 276 276 \setlength{\columnposn}{\gcolumnposn} 277 \newcommand{\setgcolumn}[1]{\global\gcolumnposn=#1\global\columnposn=\gcolumnposn} 277 278 \newcommand{\C}[2][\@empty]{\ifx#1\@empty\else\global\setlength{\columnposn}{#1}\global\columnposn=\columnposn\fi\hfill\makebox[\textwidth-\columnposn][l]{\lst@basicstyle{\LstCommentStyle{#2}}}} 278 279 \newcommand{\CRT}{\global\columnposn=\gcolumnposn} … … 301 302 showlines=true, % show blank lines at end of code 302 303 aboveskip=4pt, % spacing above/below code block 303 belowskip= 0pt,304 belowskip=2pt, 304 305 numberstyle=\footnotesize\sf, % numbering style 305 306 % replace/adjust listing characters that look bad in sanserif 306 307 literate= 307 308 {-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.75ex}{0.1ex}}}}1 308 {^}{\raisebox{0.6ex}{$\scripts criptstyle\land\,$}}1309 {^}{\raisebox{0.6ex}{$\scriptstyle\land\,$}}1 309 310 {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 310 311 {`}{\ttfamily\upshape\hspace*{-0.3ex}`}1 -
doc/LaTeXmacros/lstlang.sty
r8514bcf8 rcfcbd03 8 8 %% Created On : Sat May 13 16:34:42 2017 9 9 %% Last Modified By : Peter A. Buhr 10 %% Last Modified On : T ue May 2 08:52:35 202311 %% Update Count : 3 010 %% Last Modified On : Thu Sep 21 08:40:05 2023 11 %% Update Count : 31 12 12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 13 … … 134 134 morekeywords={ 135 135 _Accept, _AcceptReturn, _AcceptWait, _Actor, _At, _Catch, _CatchResume, _CorActor, _Cormonitor, _Coroutine, 136 _Disable, _Else, _Enable, _Event, _ Finally, _Monitor, _Mutex, _Nomutex, _PeriodicTask, _RealTimeTask,136 _Disable, _Else, _Enable, _Event, _Exception, _Finally, _Monitor, _Mutex, _Nomutex, _PeriodicTask, _RealTimeTask, 137 137 _Resume, _ResumeTop, _Select, _SporadicTask, _Task, _Timeout, _When, _With, _Throw}, 138 138 } -
doc/bibliography/pl.bib
r8514bcf8 rcfcbd03 4113 4113 title = {High-Performance Extended Actors}, 4114 4114 journal = spe, 4115 year = 2022, 4116 note = {submitted July 2022}, 4115 year = 2023, 4116 month = sep, 4117 note = {\url{https://onlinelibrary.wiley.com/doi/pdf/10.1002/spe.3262}} 4117 4118 } 4118 4119 -
doc/user/user.tex
r8514bcf8 rcfcbd03 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Thu Sep 28 22:40:52202314 %% Update Count : 5 57813 %% Last Modified On : Sat Sep 30 22:46:19 2023 14 %% Update Count : 5658 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 65 65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 66 66 67 \setlength{\gcolumnposn}{3in}68 67 \CFAStyle % use default CFA format-style 68 \setgcolumn{2.25in} 69 69 %\lstset{language=CFA} % CFA default lnaguage 70 70 \lstnewenvironment{C++}[1][] % use C++ style … … 537 537 Keyword clashes are accommodated by syntactic transformations using the \CFA backquote escape-mechanism: 538 538 \begin{cfa} 539 int ®``®coroutine = 3; 539 int ®``®coroutine = 3; $\C{// make keyword an identifier}$ 540 540 double ®``®forall = 3.5; 541 541 \end{cfa} … … 547 547 \begin{cfa} 548 548 // include file uses the CFA keyword "with". 549 #if ! defined( with ) 550 #define with ®``®with 549 #if ! defined( with ) $\C{// nesting ?}$ 550 #define with ®``®with $\C{// make keyword an identifier}$ 551 551 #define __CFA_BFD_H__ 552 552 #endif 553 $\R{\#include\_next} <bfdlink.h>$ 553 $\R{\#include\_next} <bfdlink.h>$ $\C{// must have internal check for multiple expansion}$ 554 554 #if defined( with ) && defined( __CFA_BFD_H__ ) $\C{// reset only if set}$ 555 555 #undef with … … 566 566 Numeric constants are extended to allow \Index{underscore}s\index{constant!underscore} as a separator, \eg: 567 567 \begin{cfa} 568 2®_®147®_®483®_®648; 569 56®_®ul; 570 0®_®377; 571 0x®_®ff®_®ff; 572 0x®_®ef3d®_®aa5c; 573 3.141®_®592®_®654; 574 10®_®e®_®+1®_®00; 575 0x®_®ff®_®ff®_®p®_®3; 576 0x®_®1.ffff®_®ffff®_®p®_®128®_®l; 568 2®_®147®_®483®_®648; $\C{// decimal constant}$ 569 56®_®ul; $\C{// decimal unsigned long constant}$ 570 0®_®377; $\C{// octal constant}$ 571 0x®_®ff®_®ff; $\C{// hexadecimal constant}$ 572 0x®_®ef3d®_®aa5c; $\C{// hexadecimal constant}$ 573 3.141®_®592®_®654; $\C{// floating constant}$ 574 10®_®e®_®+1®_®00; $\C{// floating constant}$ 575 0x®_®ff®_®ff®_®p®_®3; $\C{// hexadecimal floating}$ 576 0x®_®1.ffff®_®ffff®_®p®_®128®_®l; $\C{// hexadecimal floating long constant}$ 577 577 L®_®$"\texttt{\textbackslash{x}}$®_®$\texttt{ff}$®_®$\texttt{ee}"$; $\C{// wide character constant}$ 578 578 \end{cfa} … … 604 604 605 605 There are exponentiation operators for integral and floating types, including the builtin \Index{complex} types. 606 Integral exponentiation\index{exponentiation!unsigned integral} is performed with repeated multiplication \footnote{The multiplication computation is $O(\log y)$.} (or shifting if the exponent is 2).606 Integral exponentiation\index{exponentiation!unsigned integral} is performed with repeated multiplication ($O(\log y)$ multiplies or shifting if the exponent is 2). 607 607 Overflow for a large exponent or negative exponent returns zero. 608 608 Floating exponentiation\index{exponentiation!floating} is performed using \Index{logarithm}s\index{exponentiation!logarithm}, so the exponent cannot be negative. 609 609 \begin{cfa} 610 sout | 1 ®\® 0 | 1 ®\® 1 | 2 ®\® 8 | -4 ®\® 3 | 5 ®\® 3 | 5 ®\® 32 | 5L ®\® 32 | 5L ®\® 64 | -4 ®\® -3 | -4.0 ®\® -3 | 4.0 ®\® 2.1 611 | (1.0f+2.0fi) ®\® (3.0f+2.0fi); 610 sout | 1 ®\® 0 | 1 ®\® 1 | 2 ®\® 8 | -4 ®\® 3 | 5 ®\® 3 | 5 ®\® 32 | 5L ®\® 32 | 5L ®\® 64 | -4 ®\® -3 | -4.0 ®\® -3 | 4.0 ®\® 2.1 | (1.0f+2.0fi) ®\® (3.0f+2.0fi); 612 611 1 1 256 -64 125 ®0® 3273344365508751233 ®0® ®0® -0.015625 18.3791736799526 0.264715-1.1922i 613 612 \end{cfa} … … 622 621 T ?®\®?( T ep, unsigned long int y ); 623 622 \end{cfa} 624 Theuser type ©T© must define multiplication, one (©1©), and ©*©.623 A user type ©T© must define multiplication, one (©1©), and ©*©. 625 624 626 625 … … 636 635 Declarations in the \Indexc{do}-©while© condition are not useful because they appear after the loop body.} 637 636 \begin{cfa} 638 if ( ®int x = f()® ) ... 639 if ( ®int x = f(), y = g()® ) ... 637 if ( ®int x = f()® ) ... $\C{// x != 0}$ 638 if ( ®int x = f(), y = g()® ) ... $\C{// x != 0 \&\& y != 0}$ 640 639 if ( ®int x = f(), y = g(); x < y® ) ... $\C{// relational expression}$ 641 640 if ( ®struct S { int i; } x = { f() }; x.i < 4® ) $\C{// relational expression}$ 642 641 643 while ( ®int x = f()® ) ... 642 while ( ®int x = f()® ) ... $\C{// x != 0}$ 644 643 while ( ®int x = f(), y = g()® ) ... $\C{// x != 0 \&\& y != 0}$ 645 644 while ( ®int x = f(), y = g(); x < y® ) ... $\C{// relational expression}$ … … 655 654 \label{s:caseClause} 656 655 657 C restricts the \Indexc{case} clause of a\Indexc{switch} statement to a single value.658 For multiple ©case© clauses associated with the samestatement, it is necessary to have multiple ©case© clauses rather than multiple values.656 C restricts a \Indexc{case} clause in \Indexc{switch} statement to a single value. 657 For multiple ©case© clauses prefixing a statement within the ©switch© statement, it is necessary to have multiple ©case© clauses rather than multiple values. 659 658 Requiring a ©case© clause for each value is not in the spirit of brevity normally associated with C. 660 659 Therefore, the ©case© clause is extended with a list of values. 661 660 \begin{cquote} 662 661 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}} 663 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{C}} \\ 662 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}} \\ 663 \begin{cfa} 664 switch ( i ) { 665 case 1: case 3 : case 5: 666 ... 667 case 2: case 4 : case 6: 668 ... 669 } 670 \end{cfa} 671 & 664 672 \begin{cfa} 665 673 switch ( i ) { … … 672 680 & 673 681 \begin{cfa} 674 switch ( i ) {675 case 1: case 3 : case 5:676 ...677 case 2: case 4 : case 6:678 ...679 }680 \end{cfa}681 &682 \begin{cfa}683 682 684 683 // odd values … … 690 689 \end{tabular} 691 690 \end{cquote} 692 In addition, subranges are allowed to specify case values.\footnote{ 693 gcc has the same mechanism but awkward syntax, \lstinline{2 ...42}, because a space is required after a number, otherwise the period is a decimal point.} 691 In addition, subranges are allowed to specify case values. 692 \begin{cquote} 693 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{\hspace{2em}}l@{}} 694 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{©gcc©}} \\ 694 695 \begin{cfa} 695 696 switch ( i ) { 696 case ®1~5:® $\C{// 1, 2, 3, 4, 5}$697 case 1: case 2: case 3: case 4: 697 698 ... 698 case ®10~15:® $\C{// 10, 11, 12, 13, 14, 15}$699 case 10: case 11: case 12: case 13: 699 700 ... 700 701 } 701 702 \end{cfa} 702 Lists of subranges are also allowed. 703 & 704 \begin{cfa} 705 switch ( i ) { 706 case ®1~4:® 707 ... 708 case ®10~13:® 709 ... 710 } 711 \end{cfa} 712 & 713 \begin{cfa} 714 switch ( i ) { 715 case 1$\R{\textvisiblespace}$®...®4: 716 ... 717 case 10$\R{\textvisiblespace}$®...®13: 718 ... 719 } 720 \end{cfa} 721 & 722 \begin{cfa} 723 724 // 1, 2, 3, 4 725 726 // 10, 11, 12, 13 727 728 729 \end{cfa} 730 \end{tabular} 731 \end{cquote} 732 While ©gcc© has the same range mechanism, it has an awkward syntax, ©2©\R{\textvisiblespace}©...42©, because a space is required after a number, otherwise the period is a decimal point. 733 734 \CFA also allows lists of subranges. 703 735 \begin{cfa} 704 736 case ®1~5, 12~21, 35~42®: … … 771 803 This situation is better handled by a list of case values \see{\VRef{s:caseClause}}. 772 804 While fall-through itself is not a problem, the problem occurs when fall-through is the default, as this semantics is unintuitive to many programmers and is different from most programming languages with a ©switch© statement. 773 Hence, default fall-through semantics results in a large number ofprogramming errors as programmers often \emph{forget} the ©break© statement at the end of a ©case© clause, resulting in inadvertent fall-through.805 Hence, default fall-through semantics results in a many programming errors as programmers often \emph{forget} the ©break© statement at the end of a ©case© clause, resulting in inadvertent fall-through. 774 806 775 807 \item … … 848 880 and there is only a medium amount of fall-through from one ©case© clause to the next, and most of these result from a list of case values executing common code, rather than a sequence of case actions that compound. 849 881 \end{itemize} 850 These observations put into perspective the \CFA changes to the ©switch© .882 These observations put into perspective the \CFA changes to the ©switch© statement. 851 883 \begin{enumerate} 852 884 \item … … 890 922 \begin{cfa} 891 923 switch ( x ) { 892 ®int i = 0;® 924 ®int i = 0;® $\C{// allowed only at start}$ 893 925 case 0: 894 926 ... 895 ®int j = 0;® 927 ®int j = 0;® $\C{// disallowed}$ 896 928 case 1: 897 929 { 898 ®int k = 0;® 930 ®int k = 0;® $\C{// allowed at different nesting levels}$ 899 931 ... 900 ®case 2:® 932 ®case 2:® $\C{// disallow case in nested statements}$ 901 933 } 902 934 ... … … 909 941 910 942 The \Indexc{fallthrough} clause may be non-terminating within a \Indexc{case} clause or have a target label to common code from multiple case clauses. 911 \begin{c enter}943 \begin{cquote} 912 944 \begin{tabular}{@{}lll@{}} 913 945 \begin{cfa} … … 959 991 \end{cfa} 960 992 \end{tabular} 961 \end{c enter}993 \end{cquote} 962 994 The target label must be below the \Indexc{fallthrough} and may not be nested in a control structure, and 963 995 the target label must be at the same or higher level as the containing \Indexc{case} clause and located at … … 966 998 967 999 \begin{figure} 968 \begin{tabular}{@{}l@{\hspace{ 40pt}}|l@{}}969 \multicolumn{1}{@{}c@{\hspace{ 40pt}}|}{loop control} & \multicolumn{1}{c@{}}{output} \\1000 \begin{tabular}{@{}l@{\hspace{50pt}}|l@{}} 1001 \multicolumn{1}{@{}c@{\hspace{50pt}}|}{loop control} & \multicolumn{1}{c@{}}{output} \\ 970 1002 \hline 971 1003 \begin{cfa} … … 1085 1117 The \Indexc{for}, \Indexc{while}, and \Indexc{do} loop-control allow an empty conditional, which implies a comparison value of ©1© (true). 1086 1118 \begin{cfa} 1087 while ( ®/* empty*/® )$\C{// while ( true )}$1088 for ( ®/* empty*/® )$\C{// for ( ; true; )}$1089 do ... while ( ®/* empty*/® )$\C{// do ... while ( true )}$1119 while ( ®/* empty */® ) $\C{// while ( true )}$ 1120 for ( ®/* empty */® ) $\C{// for ( ; true; )}$ 1121 do ... while ( ®/* empty */® ) $\C{// do ... while ( true )}$ 1090 1122 \end{cfa} 1091 1123 … … 1117 1149 If no type is specified for the loop index, it is the type of the high value H (when the low value is implicit) or the low value L. 1118 1150 \begin{cfa} 1119 for ( ®5® ) $\C{// typeof(5) anonymous-index; 5 is high value}$1120 for ( i; ®1.5® ~ 5.5 ) $\C{// typeof(1.5) i; 1.5 is low value}$1121 for ( ®int i®; 0 ~ 10 ~ 2 ) $\C{// int i; type is explicit}$1151 for ( ®5® ) $\C{// typeof(5) anonymous-index; 5 is high value}$ 1152 for ( i; ®1.5® ~ 5.5 ) $\C{// typeof(1.5) i; 1.5 is low value}$ 1153 for ( ®int i®; 0 ~ 10 ~ 2 ) $\C{// int i; type is explicit}$ 1122 1154 \end{cfa} 1123 1155 … … 1127 1159 H is implicit up-to exclusive range [0,H\R{)}. 1128 1160 \begin{cfa} 1129 for ( ®5® ) $\C{// for ( typeof(5) i; i < 5; i += 1 )}$1161 for ( ®5® ) $\C{// for ( typeof(5) i; i < 5; i += 1 )}$ 1130 1162 \end{cfa} 1131 1163 \item 1132 1164 ©~=© H is implicit up-to inclusive range [0,H\R{]}. 1133 1165 \begin{cfa} 1134 for ( ®~=® 5 ) $\C{// for ( typeof(5) i; i <= 5; i += 1 )}$1166 for ( ®~=® 5 ) $\C{// for ( typeof(5) i; i <= 5; i += 1 )}$ 1135 1167 \end{cfa} 1136 1168 \item 1137 1169 L ©~©\index{~@©~©} H is explicit up-to exclusive range [L,H\R{)}. 1138 1170 \begin{cfa} 1139 for ( 1 ®~® 5 ) $\C{// for ( typeof(1) i = 1; i < 5; i += 1 )}$1171 for ( 1 ®~® 5 ) $\C{// for ( typeof(1) i = 1; i < 5; i += 1 )}$ 1140 1172 \end{cfa} 1141 1173 \item 1142 1174 L ©~=©\index{~=@©~=©} H is explicit up-to inclusive range [L,H\R{]}. 1143 1175 \begin{cfa} 1144 for ( 1 ®~=® 5 ) $\C{// for ( typeof(1) i = 1; i <= 5; i += 1 )}$1176 for ( 1 ®~=® 5 ) $\C{// for ( typeof(1) i = 1; i <= 5; i += 1 )}$ 1145 1177 \end{cfa} 1146 1178 \item 1147 1179 L ©-~©\index{-~@©-~©} H is explicit down-to exclusive range [H,L\R{)}, where L and H are implicitly interchanged to make the range down-to. 1148 1180 \begin{cfa} 1149 for ( 1 ®-~® 5 ) $\C{// for ( typeof(1) i = 5; i > 0; i -= 1 )}$1181 for ( 1 ®-~® 5 ) $\C{// for ( typeof(1) i = 5; i > 0; i -= 1 )}$ 1150 1182 \end{cfa} 1151 1183 \item 1152 1184 L ©-~=©\index{-~=@©-~=©} H is explicit down-to inclusive range [H,L\R{]}, where L and H are implicitly interchanged to make the range down-to. 1153 1185 \begin{cfa} 1154 for ( 1 ®-~=® 5 ) $\C{// for ( typeof(1) i = 5; i >= 0; i -= 1 )}$1186 for ( 1 ®-~=® 5 ) $\C{// for ( typeof(1) i = 5; i >= 0; i -= 1 )}$ 1155 1187 \end{cfa} 1156 1188 \item 1157 1189 ©@© means put nothing in this field. 1158 1190 \begin{cfa} 1159 for ( i; 1 ~ ®@® ~ 2 ) $\C{// for ( typeof(1) i = 1; \R{/* empty */}; i += 2 )}$1160 for ( i; 1 ~ 10 ~ ®@® ) $\C{// for ( typeof(1) i = 1; i < 10; \R{/* empty */} )}$1161 for ( i; 1 ~ ®@® ~ ®@® ) $\C{// for ( typeof(1) i = 1; /*empty*/; \R{/* empty */} )}$1191 for ( i; 1 ~ ®@® ~ 2 ) $\C{// for ( typeof(1) i = 1; \R{/* empty */}; i += 2 )}$ 1192 for ( i; 1 ~ 10 ~ ®@® ) $\C{// for ( typeof(1) i = 1; i < 10; \R{/* empty */} )}$ 1193 for ( i; 1 ~ ®@® ~ ®@® ) $\C{// for ( typeof(1) i = 1; /*empty*/; \R{/* empty */} )}$ 1162 1194 \end{cfa} 1163 1195 L cannot be elided for the up-to range, \lstinline{@ ~ 5}, and H for the down-to range, \lstinline{1 -~ @}, because then the loop index is uninitialized. … … 1166 1198 ©:© means low another index. 1167 1199 \begin{cfa} 1168 for ( i; 5 ®:® j; 2 ~ 12 ~ 3 ) $\C{// for ( typeof(i) i = 1, j = 2; i < 5 \&\& j < 12; i += 1, j += 3 )}$1200 for ( i; 5 ®:® j; 2 ~ 12 ~ 3 ) $\C{// for ( typeof(i) i = 1, j = 2; i < 5 \&\& j < 12; i += 1, j += 3 )}$ 1169 1201 \end{cfa} 1170 1202 \end{itemize} 1171 1203 \R{Warning}: specifying the down-to range maybe unexpected because the loop control \emph{implicitly} switches the L and H values (and toggles the increment/decrement for I): 1172 1204 \begin{cfa} 1173 for ( i; 1 ~ 10 ) ${\C[1.5in]{// up range}$1174 for ( i; 1 -~ 10 ) ${\C{// down range}$1175 for ( i; ®10 -~ 1® ) ${\C{// \R{WRONG down range!}}\CRT}$1205 for ( i; 1 ~ 10 ) ${\C{// up range}$ 1206 for ( i; 1 -~ 10 ) ${\C{// down range}$ 1207 for ( i; ®10 -~ 1® ) ${\C{// \R{WRONG down range!}}}$ 1176 1208 \end{cfa} 1177 1209 The reason for this semantics is that the range direction can be toggled by adding/removing the minus, ©'-'©, versus interchanging the L and H expressions, which has a greater chance of introducing errors. … … 1190 1222 1191 1223 \begin{figure} 1192 \centering1193 1224 \begin{lrbox}{\myboxA} 1194 \begin{cfa}[tabsize= 3]1225 \begin{cfa}[tabsize=4] 1195 1226 ®Compound:® { 1196 1227 ®Try:® try { … … 1222 1253 1223 1254 \begin{lrbox}{\myboxB} 1224 \begin{cfa}[tabsize= 3]1255 \begin{cfa}[tabsize=4] 1225 1256 { 1226 1257 … … 1251 1282 \end{lrbox} 1252 1283 1253 \subfloat[ \CFA]{\label{f:CFibonacci}\usebox\myboxA}1284 \subfloat[C]{\label{f:CFAFibonacciGen}\usebox\myboxB} 1254 1285 \hspace{3pt} 1255 1286 \vrule 1256 1287 \hspace{3pt} 1257 \subfloat[ C]{\label{f:CFAFibonacciGen}\usebox\myboxB}1288 \subfloat[\CFA]{\label{f:CFibonacci}\usebox\myboxA} 1258 1289 \caption{Multi-level Exit} 1259 1290 \label{f:MultiLevelExit} … … 1289 1320 int a[10]; 1290 1321 \end{cfa} 1291 \begin{tabular}{@{}l ll@{}}1322 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{3em}}l@{}} 1292 1323 \begin{cfa} 1293 1324 … … 1330 1361 Grouping heterogeneous data into an \newterm{aggregate} (structure/union) is a common programming practice, and aggregates may be nested: 1331 1362 \begin{cfa} 1332 struct Person { $\C{// aggregate}$ 1333 struct Name { char first[20], last[20]; } name $\C{// nesting}$ 1334 struct Address { ... } address $\C{// nesting}$ 1363 struct Person { $\C{// aggregate}$ 1364 struct Name { $\C{// nesting}$ 1365 char first[20], last[20]; 1366 } name; 1367 struct Address { $\C{// nesting}$ 1368 ... 1369 } address; 1335 1370 int sex; 1336 1371 }; … … 1339 1374 \begin{cfa} 1340 1375 Person p 1341 ®p.®name; ®p.®address; ®p.®sex; 1376 ®p.®name; ®p.®address; ®p.®sex; $\C{// access containing fields}$ 1342 1377 \end{cfa} 1343 1378 which extends to multiple levels of qualification for nested aggregates and multiple aggregates. … … 1354 1389 \begin{cfa} 1355 1390 struct S { 1356 struct $\R{\LstCommentStyle{/* unnamed */}}$ { int g, h; } __attribute__(( aligned(64) ));1391 struct $\R{\LstCommentStyle{/* unnamed */}}$ { int g, h; } __attribute__(( aligned(64) )); 1357 1392 int tag; 1358 union $\R{\LstCommentStyle{/* unnamed */}}$ {1393 union $\R{\LstCommentStyle{/* unnamed */}}$ { 1359 1394 struct { char c1, c2; } __attribute__(( aligned(128) )); 1360 1395 struct { int i1, i2; }; … … 1370 1405 struct S { 1371 1406 char ®c®; int ®i®; double ®d®; 1372 void f( /* S * this */ ) { 1373 ®c®; ®i®; ®d®; 1407 void f( /* S * this */ ) { $\C{// implicit ``this'' parameter}$ 1408 ®c®; ®i®; ®d®; $\C{// this->c; this->i; this->d;}$ 1374 1409 } 1375 1410 } … … 1379 1414 \begin{cfa} 1380 1415 struct T { 1381 char ®m®; int ®i®; double ®n®; 1416 char ®m®; int ®i®; double ®n®; $\C{// derived class variables}$ 1382 1417 }; 1383 1418 struct S : public T { 1384 char ®c®; int ®i®; double ®d®; 1419 char ®c®; int ®i®; double ®d®; $\C{// class variables}$ 1385 1420 void g( double ®d®, T & t ) { 1386 d; ®t®.m; ®t®.i; ®t®.n; 1387 c; i; ®this->®d; ®S::®d; 1388 m; ®T::®i; n; 1421 d; ®t®.m; ®t®.i; ®t®.n; $\C{// function parameter}$ 1422 c; i; ®this->®d; ®S::®d; $\C{// class S variables}$ 1423 m; ®T::®i; n; $\C{// class T variables}$ 1389 1424 } 1390 1425 }; … … 1396 1431 Hence, the qualified fields become variables with the side-effect that it is simpler to write, easier to read, and optimize field references in a block. 1397 1432 \begin{cfa} 1398 void f( S & this ) ®with ( this )® { 1399 ®c®; ®i®; ®d®; 1433 void f( S & this ) ®with ( this )® { $\C{// with statement}$ 1434 ®c®; ®i®; ®d®; $\C{// this.c, this.i, this.d}$ 1400 1435 } 1401 1436 \end{cfa} 1402 1437 with the generality of opening multiple aggregate-parameters: 1403 1438 \begin{cfa} 1404 void g( S & s, T & t ) ®with ( s, t )® { 1405 c; ®s.®i; d; 1406 m; ®t.®i; n; 1439 void g( S & s, T & t ) ®with ( s, t )® {$\C{// multiple aggregate parameters}$ 1440 c; ®s.®i; d; $\C{// s.c, s.i, s.d}$ 1441 m; ®t.®i; n; $\C{// t.m, t.i, t.n}$ 1407 1442 } 1408 1443 \end{cfa} … … 1427 1462 struct R { int ®i®; int j; double ®m®; } r, w; 1428 1463 with ( r, q ) { 1429 j + k; 1430 m = 5.0; 1431 m = 1; 1432 int a = m; 1433 double b = m; 1434 int c = r.i + q.i; 1435 (double)m; 1464 j + k; $\C{// unambiguous, r.j + q.k}$ 1465 m = 5.0; $\C{// unambiguous, q.m = 5.0}$ 1466 m = 1; $\C{// unambiguous, r.m = 1}$ 1467 int a = m; $\C{// unambiguous, a = r.i }$ 1468 double b = m; $\C{// unambiguous, b = q.m}$ 1469 int c = r.i + q.i; $\C{// disambiguate with qualification}$ 1470 (double)m; $\C{// disambiguate with cast}$ 1436 1471 } 1437 1472 \end{cfa} … … 1441 1476 \begin{cfa} 1442 1477 with ( r ) { 1443 i; 1478 i; $\C{// unambiguous, r.i}$ 1444 1479 with ( q ) { 1445 i; 1480 i; $\C{// unambiguous, q.i}$ 1446 1481 } 1447 1482 } … … 1450 1485 A cast can also be used to disambiguate among overload variables in a ©with© \emph{expression}: 1451 1486 \begin{cfa} 1452 with ( w ) { ... } 1453 with ( (Q)w ) { ... } 1487 with ( w ) { ... } $\C{// ambiguous, same name and no context}$ 1488 with ( (Q)w ) { ... } $\C{// unambiguous, cast}$ 1454 1489 \end{cfa} 1455 1490 Because there is no left-side in the ©with© expression to implicitly disambiguate between the ©w© variables, it is necessary to explicitly disambiguate by casting ©w© to type ©Q© or ©R©. … … 1458 1493 \begin{cfa} 1459 1494 void f( S & s, char c ) with ( s ) { 1460 ®s.c = c;® i = 3; d = 5.5; 1495 ®s.c = c;® i = 3; d = 5.5; $\C{// initialize fields}$ 1461 1496 } 1462 1497 \end{cfa} … … 1464 1499 To solve this problem, parameters \emph{not} explicitly opened are treated like an initialized aggregate: 1465 1500 \begin{cfa} 1466 struct Params { 1501 struct Params { $\C{// s explicitly opened so S \& s elided}$ 1467 1502 char c; 1468 1503 } params; … … 1483 1518 Transfer of control can be local, within a routine, or non-local, among routines. 1484 1519 Non-local transfer can cause stack unwinding, \ie non-local routine termination, depending on the kind of raise. 1520 1521 Currently, \CFA uses macros ©ExceptionDecl© and ©ExceptionInst© to declare and instantiate an exception. 1522 \begin{cfa} 1523 #include <Exception.hfa> 1524 ®ExceptionDecl®( E, // must be global scope 1525 ... // exception fields 1526 ); 1527 try { 1528 ... 1529 if ( ... ) ®throwResume® ®ExceptionInst®( E, /* intialization */ ); 1530 if ( ... ) ®throw® ®ExceptionInst®( E, /* intialization */ ); 1531 ... 1532 } ®catchResume®( E * ) { // must be pointer 1533 ... 1534 } catch( E * ) { 1535 ... 1536 } 1537 \end{cfa} 1538 1485 1539 \begin{cfa} 1486 1540 exception_t E {}; $\C{// exception type}$ … … 1491 1545 try { 1492 1546 f(...); 1493 } catch( E e ; $boolean-predicate$ ) { 1547 } catch( E e ; $boolean-predicate$ ) { $\C{// termination handler}$ 1494 1548 // recover and continue 1495 1549 } catchResume( E e ; $boolean-predicate$ ) { $\C{// resumption handler}$ … … 1503 1557 The ©catch© and ©catchResume© handlers may appear in any oder. 1504 1558 However, the ©finally© clause must appear at the end of the ©try© statement. 1559 1560 1561 \section{Non-local Exception} 1562 1563 \begin{cfa} 1564 void main() { 1565 try { 1566 _Enable { 1567 ... resume(); ... 1568 } 1569 } ®catchResume®( E & ) { // should be reference 1570 ... 1571 } catch( E & ) { 1572 ... 1573 } 1574 } 1575 \end{cfa} 1505 1576 1506 1577 … … 1568 1639 \begin{cquote} 1569 1640 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1570 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1641 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1642 \begin{cfa}[moredelim={**[is][\color{blue}]{\#}{\#}}] 1643 ®int® #*# x1 #[5]#; 1644 ®int® #(*#x2#)[5]#; 1645 #int (*#f®( int p )®#)[5]#; 1646 \end{cfa} 1647 & 1571 1648 \begin{cfa}[moredelim={**[is][\color{blue}]{\#}{\#}}] 1572 1649 #[5] *# ®int® x1; 1573 1650 #* [5]# ®int® x2; 1574 1651 #[* [5] int]# f®( int p )®; 1575 \end{cfa}1576 &1577 \begin{cfa}[moredelim={**[is][\color{blue}]{\#}{\#}}]1578 ®int® #*# x1 #[5]#;1579 ®int® #(*#x2#)[5]#;1580 #int (*#f®( int p )®#)[5]#;1581 1652 \end{cfa} 1582 1653 \end{tabular} … … 1588 1659 \begin{cquote} 1589 1660 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1590 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1661 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1662 \begin{cfa} 1663 int ®*®x, ®*®y; 1664 \end{cfa} 1665 & 1591 1666 \begin{cfa} 1592 1667 ®*® int x, y; 1593 \end{cfa}1594 &1595 \begin{cfa}1596 int ®*®x, ®*®y;1597 1668 \end{cfa} 1598 1669 \end{tabular} … … 1601 1672 \begin{cquote} 1602 1673 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1603 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1674 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1675 \begin{cfa} 1676 int ®*®x, y; 1677 1678 \end{cfa} 1679 & 1604 1680 \begin{cfa} 1605 1681 ®*® int x; 1606 1682 int y; 1607 \end{cfa}1608 &1609 \begin{cfa}1610 int ®*®x, y;1611 1612 1683 \end{cfa} 1613 1684 \end{tabular} … … 1617 1688 \begin{cquote} 1618 1689 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}} 1619 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{C}} \\ 1690 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}} \\ 1691 \begin{cfa} 1692 int z[ 5 ]; 1693 char * w[ 5 ]; 1694 double (* v)[ 5 ]; 1695 struct s { 1696 int f0:3; 1697 int * f1; 1698 int * f2[ 5 ] 1699 }; 1700 \end{cfa} 1701 & 1620 1702 \begin{cfa} 1621 1703 [ 5 ] int z; … … 1630 1712 & 1631 1713 \begin{cfa} 1632 int z[ 5 ];1633 char * w[ 5 ];1634 double (* v)[ 5 ];1635 struct s {1636 int f0:3;1637 int * f1;1638 int * f2[ 5 ]1639 };1640 \end{cfa}1641 &1642 \begin{cfa}1643 1714 // array of 5 integers 1644 1715 // array of 5 pointers to char … … 1656 1727 \begin{cquote} 1657 1728 \begin{tabular}{@{}l@{\hspace{1em}}l@{\hspace{1em}}l@{}} 1658 \multicolumn{1}{c@{\hspace{1em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{1em}}}{\textbf{C}} \\ 1729 \multicolumn{1}{c@{\hspace{1em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{1em}}}{\textbf{\CFA}} \\ 1730 \begin{cfa} 1731 int const * const x; 1732 const int (* const y)[ 5 ] 1733 \end{cfa} 1734 & 1659 1735 \begin{cfa} 1660 1736 const * const int x; 1661 1737 const * [ 5 ] const int y; 1662 \end{cfa}1663 &1664 \begin{cfa}1665 int const * const x;1666 const int (* const y)[ 5 ]1667 1738 \end{cfa} 1668 1739 & … … 1677 1748 \begin{cquote} 1678 1749 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}} 1679 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{C}} \\ 1750 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}} \\ 1751 \begin{cfa} 1752 int extern x[ 5 ]; 1753 const int static * y; 1754 \end{cfa} 1755 & 1680 1756 \begin{cfa} 1681 1757 extern [ 5 ] int x; 1682 1758 static * const int y; 1683 \end{cfa}1684 &1685 \begin{cfa}1686 int extern x[ 5 ];1687 const int static * y;1688 1759 \end{cfa} 1689 1760 & … … 1698 1769 \begin{cquote} 1699 1770 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1700 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1771 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1772 \begin{cfa} 1773 y = (int *)x; 1774 i = sizeof(int * [ 5 ]); 1775 \end{cfa} 1776 & 1701 1777 \begin{cfa} 1702 1778 y = (* int)x; 1703 1779 i = sizeof([ 5 ] * int); 1704 \end{cfa}1705 &1706 \begin{cfa}1707 y = (int *)x;1708 i = sizeof(int * [ 5 ]);1709 1780 \end{cfa} 1710 1781 \end{tabular} … … 1901 1972 \begin{cquote} 1902 1973 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1903 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1974 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{Cy}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1975 \begin{cfa} 1976 const int * ®const® * ®const® ccp; 1977 1978 \end{cfa} 1979 & 1904 1980 \begin{cfa} 1905 1981 ®const® * ®const® * const int ccp; 1906 1982 ®const® & ®const® & const int ccr; 1907 \end{cfa}1908 &1909 \begin{cfa}1910 const int * ®const® * ®const® ccp;1911 1912 1983 \end{cfa} 1913 1984 \end{tabular} … … 2070 2141 \begin{cfa} 2071 2142 int x, &r = ®x®, f( int & p ); $\C{// lvalue variable (int) convert to reference (int \&)}$ 2072 f( ®x® ); $\C{// lvalue variable (int) convert to reference (int \&)} $2143 f( ®x® ); $\C{// lvalue variable (int) convert to reference (int \&)}\CRT$ 2073 2144 \end{cfa} 2074 2145 Conversion can restrict a type, where ©cv1© $\le$ ©cv2©, \eg passing an ©int© to a ©const volatile int &©, which has low cost. … … 8630 8701 \begin{cquote} 8631 8702 \begin{tabular}{@{}l@{\hspace{\parindentlnth}}|@{\hspace{\parindentlnth}}l@{}} 8632 \multicolumn{1}{@{}c|@{\hspace{\parindentlnth}}}{\textbf{ \CFA}} & \multicolumn{1}{@{\hspace{\parindentlnth}}c@{}}{\textbf{C}} \\8703 \multicolumn{1}{@{}c|@{\hspace{\parindentlnth}}}{\textbf{C}} & \multicolumn{1}{@{\hspace{\parindentlnth}}c@{}}{\textbf{\CFA}} \\ 8633 8704 \hline 8634 \begin{cfa}8635 #include <gmp.hfa>$\indexc{gmp}$8636 int main( void ) {8637 sout | "Factorial Numbers";8638 Int fact = 1;8639 8640 sout | 0 | fact;8641 for ( i; 40 ) {8642 fact *= i;8643 sout | i | fact;8644 }8645 }8646 \end{cfa}8647 &8648 8705 \begin{cfa} 8649 8706 #include <gmp.h>$\indexc{gmp.h}$ … … 8656 8713 ®mpz_mul_ui®( fact, fact, i ); 8657 8714 ®gmp_printf®( "%d %Zd\n", i, fact ); 8715 } 8716 } 8717 \end{cfa} 8718 & 8719 \begin{cfa} 8720 #include <gmp.hfa>$\indexc{gmp}$ 8721 int main( void ) { 8722 sout | "Factorial Numbers"; 8723 Int fact = 1; 8724 8725 sout | 0 | fact; 8726 for ( i; 40 ) { 8727 fact *= i; 8728 sout | i | fact; 8658 8729 } 8659 8730 }
Note: See TracChangeset
for help on using the changeset viewer.