Changes in / [cfcbd03:8514bcf8]
- Location:
- doc
- Files:
-
- 5 edited
-
LaTeXmacros/common.sty (modified) (3 diffs)
-
LaTeXmacros/common.tex (modified) (3 diffs)
-
LaTeXmacros/lstlang.sty (modified) (2 diffs)
-
bibliography/pl.bib (modified) (1 diff)
-
user/user.tex (modified) (51 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/LaTeXmacros/common.sty
rcfcbd03 r8514bcf8 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Fri Sep 29 16:48:59202314 %% Update Count : 58 713 %% Last Modified On : Sun Jul 16 08:28:52 2023 14 %% Update Count : 586 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}275 274 \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}}}} 276 275 \newcommand{\CRT}{\global\columnposn=\gcolumnposn} … … 303 302 literate= 304 303 {-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.75ex}{0.1ex}}}}1 305 {^}{\raisebox{0.6ex}{$\scripts tyle\land\,$}}1304 {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1 306 305 {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 307 306 {`}{\ttfamily\upshape\hspace*{-0.3ex}`}1 -
doc/LaTeXmacros/common.tex
rcfcbd03 r8514bcf8 11 11 %% Created On : Sat Apr 9 10:06:17 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Fri Sep 29 16:49:02202314 %% Update Count : 5 9013 %% Last Modified On : Fri Jul 21 09:02:00 2023 14 %% Update Count : 576 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}278 277 \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}}}} 279 278 \newcommand{\CRT}{\global\columnposn=\gcolumnposn} … … 302 301 showlines=true, % show blank lines at end of code 303 302 aboveskip=4pt, % spacing above/below code block 304 belowskip= 2pt,303 belowskip=0pt, 305 304 numberstyle=\footnotesize\sf, % numbering style 306 305 % replace/adjust listing characters that look bad in sanserif 307 306 literate= 308 307 {-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.75ex}{0.1ex}}}}1 309 {^}{\raisebox{0.6ex}{$\scripts tyle\land\,$}}1308 {^}{\raisebox{0.6ex}{$\scriptscriptstyle\land\,$}}1 310 309 {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 311 310 {`}{\ttfamily\upshape\hspace*{-0.3ex}`}1 -
doc/LaTeXmacros/lstlang.sty
rcfcbd03 r8514bcf8 8 8 %% Created On : Sat May 13 16:34:42 2017 9 9 %% Last Modified By : Peter A. Buhr 10 %% Last Modified On : T hu Sep 21 08:40:05 202311 %% Update Count : 3 110 %% Last Modified On : Tue May 2 08:52:35 2023 11 %% Update Count : 30 12 12 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 13 13 … … 134 134 morekeywords={ 135 135 _Accept, _AcceptReturn, _AcceptWait, _Actor, _At, _Catch, _CatchResume, _CorActor, _Cormonitor, _Coroutine, 136 _Disable, _Else, _Enable, _Event, _ Exception, _Finally, _Monitor, _Mutex, _Nomutex, _PeriodicTask, _RealTimeTask,136 _Disable, _Else, _Enable, _Event, _Finally, _Monitor, _Mutex, _Nomutex, _PeriodicTask, _RealTimeTask, 137 137 _Resume, _ResumeTop, _Select, _SporadicTask, _Task, _Timeout, _When, _With, _Throw}, 138 138 } -
doc/bibliography/pl.bib
rcfcbd03 r8514bcf8 4113 4113 title = {High-Performance Extended Actors}, 4114 4114 journal = spe, 4115 year = 2023, 4116 month = sep, 4117 note = {\url{https://onlinelibrary.wiley.com/doi/pdf/10.1002/spe.3262}} 4115 year = 2022, 4116 note = {submitted July 2022}, 4118 4117 } 4119 4118 -
doc/user/user.tex
rcfcbd03 r8514bcf8 11 11 %% Created On : Wed Apr 6 14:53:29 2016 12 12 %% Last Modified By : Peter A. Buhr 13 %% Last Modified On : Sat Sep 30 22:46:19202314 %% Update Count : 5 65813 %% Last Modified On : Thu Sep 28 22:40:52 2023 14 %% Update Count : 5578 15 15 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 16 16 … … 65 65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 66 66 67 \setlength{\gcolumnposn}{3in} 67 68 \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; $\C{// make keyword an identifier}$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 ) $\C{// nesting ?}$550 #define with ®``®with $\C{// make keyword an identifier}$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>$ $\C{// must have internal check for multiple expansion}$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; $\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}$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 ($O(\log y)$ multipliesor shifting if the exponent is 2).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). 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 | (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 611 | (1.0f+2.0fi) ®\® (3.0f+2.0fi); 611 612 1 1 256 -64 125 ®0® 3273344365508751233 ®0® ®0® -0.015625 18.3791736799526 0.264715-1.1922i 612 613 \end{cfa} … … 621 622 T ?®\®?( T ep, unsigned long int y ); 622 623 \end{cfa} 623 Auser type ©T© must define multiplication, one (©1©), and ©*©.624 The user type ©T© must define multiplication, one (©1©), and ©*©. 624 625 625 626 … … 635 636 Declarations in the \Indexc{do}-©while© condition are not useful because they appear after the loop body.} 636 637 \begin{cfa} 637 if ( ®int x = f()® ) ... $\C{// x != 0}$638 if ( ®int x = f(), y = g()® ) ... $\C{// x != 0 \&\& y != 0}$638 if ( ®int x = f()® ) ... $\C{// x != 0}$ 639 if ( ®int x = f(), y = g()® ) ... $\C{// x != 0 \&\& y != 0}$ 639 640 if ( ®int x = f(), y = g(); x < y® ) ... $\C{// relational expression}$ 640 641 if ( ®struct S { int i; } x = { f() }; x.i < 4® ) $\C{// relational expression}$ 641 642 642 while ( ®int x = f()® ) ... $\C{// x != 0}$643 while ( ®int x = f()® ) ... $\C{// x != 0}$ 643 644 while ( ®int x = f(), y = g()® ) ... $\C{// x != 0 \&\& y != 0}$ 644 645 while ( ®int x = f(), y = g(); x < y® ) ... $\C{// relational expression}$ … … 654 655 \label{s:caseClause} 655 656 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.657 C restricts the \Indexc{case} clause of a \Indexc{switch} statement to a single value. 658 For multiple ©case© clauses associated with the same statement, it is necessary to have multiple ©case© clauses rather than multiple values. 658 659 Requiring a ©case© clause for each value is not in the spirit of brevity normally associated with C. 659 660 Therefore, the ©case© clause is extended with a list of values. 660 661 \begin{cquote} 661 662 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}} 662 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}} \\ 663 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{C}} \\ 664 \begin{cfa} 665 switch ( i ) { 666 case ®1, 3, 5®: 667 ... 668 case ®2, 4, 6®: 669 ... 670 } 671 \end{cfa} 672 & 663 673 \begin{cfa} 664 674 switch ( i ) { … … 671 681 & 672 682 \begin{cfa} 673 switch ( i ) {674 case ®1, 3, 5®:675 ...676 case ®2, 4, 6®:677 ...678 }679 \end{cfa}680 &681 \begin{cfa}682 683 683 684 // odd values … … 689 690 \end{tabular} 690 691 \end{cquote} 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©}} \\ 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.} 695 694 \begin{cfa} 696 695 switch ( i ) { 697 case 1: case 2: case 3: case 4:696 case ®1~5:® $\C{// 1, 2, 3, 4, 5}$ 698 697 ... 699 case 10: case 11: case 12: case 13:698 case ®10~15:® $\C{// 10, 11, 12, 13, 14, 15}$ 700 699 ... 701 700 } 702 701 \end{cfa} 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. 702 Lists of subranges are also allowed. 735 703 \begin{cfa} 736 704 case ®1~5, 12~21, 35~42®: … … 803 771 This situation is better handled by a list of case values \see{\VRef{s:caseClause}}. 804 772 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. 805 Hence, default fall-through semantics results in a manyprogramming errors as programmers often \emph{forget} the ©break© statement at the end of a ©case© clause, resulting in inadvertent fall-through.773 Hence, default fall-through semantics results in a large number of programming errors as programmers often \emph{forget} the ©break© statement at the end of a ©case© clause, resulting in inadvertent fall-through. 806 774 807 775 \item … … 880 848 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. 881 849 \end{itemize} 882 These observations put into perspective the \CFA changes to the ©switch© statement.850 These observations put into perspective the \CFA changes to the ©switch©. 883 851 \begin{enumerate} 884 852 \item … … 922 890 \begin{cfa} 923 891 switch ( x ) { 924 ®int i = 0;® $\C{// allowed only at start}$892 ®int i = 0;® $\C{// allowed only at start}$ 925 893 case 0: 926 894 ... 927 ®int j = 0;® $\C{// disallowed}$895 ®int j = 0;® $\C{// disallowed}$ 928 896 case 1: 929 897 { 930 ®int k = 0;® $\C{// allowed at different nesting levels}$898 ®int k = 0;® $\C{// allowed at different nesting levels}$ 931 899 ... 932 ®case 2:® $\C{// disallow case in nested statements}$900 ®case 2:® $\C{// disallow case in nested statements}$ 933 901 } 934 902 ... … … 941 909 942 910 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. 943 \begin{c quote}911 \begin{center} 944 912 \begin{tabular}{@{}lll@{}} 945 913 \begin{cfa} … … 991 959 \end{cfa} 992 960 \end{tabular} 993 \end{c quote}961 \end{center} 994 962 The target label must be below the \Indexc{fallthrough} and may not be nested in a control structure, and 995 963 the target label must be at the same or higher level as the containing \Indexc{case} clause and located at … … 998 966 999 967 \begin{figure} 1000 \begin{tabular}{@{}l@{\hspace{ 50pt}}|l@{}}1001 \multicolumn{1}{@{}c@{\hspace{ 50pt}}|}{loop control} & \multicolumn{1}{c@{}}{output} \\968 \begin{tabular}{@{}l@{\hspace{40pt}}|l@{}} 969 \multicolumn{1}{@{}c@{\hspace{40pt}}|}{loop control} & \multicolumn{1}{c@{}}{output} \\ 1002 970 \hline 1003 971 \begin{cfa} … … 1117 1085 The \Indexc{for}, \Indexc{while}, and \Indexc{do} loop-control allow an empty conditional, which implies a comparison value of ©1© (true). 1118 1086 \begin{cfa} 1119 while ( ®/* empty */® )$\C{// while ( true )}$1120 for ( ®/* empty */® )$\C{// for ( ; true; )}$1121 do ... while ( ®/* empty */® )$\C{// do ... while ( true )}$1087 while ( ®/*empty*/® ) $\C{// while ( true )}$ 1088 for ( ®/*empty*/® ) $\C{// for ( ; true; )}$ 1089 do ... while ( ®/*empty*/® ) $\C{// do ... while ( true )}$ 1122 1090 \end{cfa} 1123 1091 … … 1149 1117 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. 1150 1118 \begin{cfa} 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}$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}$ 1154 1122 \end{cfa} 1155 1123 … … 1159 1127 H is implicit up-to exclusive range [0,H\R{)}. 1160 1128 \begin{cfa} 1161 for ( ®5® ) $\C{// for ( typeof(5) i; i < 5; i += 1 )}$1129 for ( ®5® ) $\C{// for ( typeof(5) i; i < 5; i += 1 )}$ 1162 1130 \end{cfa} 1163 1131 \item 1164 1132 ©~=© H is implicit up-to inclusive range [0,H\R{]}. 1165 1133 \begin{cfa} 1166 for ( ®~=® 5 ) $\C{// for ( typeof(5) i; i <= 5; i += 1 )}$1134 for ( ®~=® 5 ) $\C{// for ( typeof(5) i; i <= 5; i += 1 )}$ 1167 1135 \end{cfa} 1168 1136 \item 1169 1137 L ©~©\index{~@©~©} H is explicit up-to exclusive range [L,H\R{)}. 1170 1138 \begin{cfa} 1171 for ( 1 ®~® 5 ) $\C{// for ( typeof(1) i = 1; i < 5; i += 1 )}$1139 for ( 1 ®~® 5 ) $\C{// for ( typeof(1) i = 1; i < 5; i += 1 )}$ 1172 1140 \end{cfa} 1173 1141 \item 1174 1142 L ©~=©\index{~=@©~=©} H is explicit up-to inclusive range [L,H\R{]}. 1175 1143 \begin{cfa} 1176 for ( 1 ®~=® 5 ) $\C{// for ( typeof(1) i = 1; i <= 5; i += 1 )}$1144 for ( 1 ®~=® 5 ) $\C{// for ( typeof(1) i = 1; i <= 5; i += 1 )}$ 1177 1145 \end{cfa} 1178 1146 \item 1179 1147 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. 1180 1148 \begin{cfa} 1181 for ( 1 ®-~® 5 ) $\C{// for ( typeof(1) i = 5; i > 0; i -= 1 )}$1149 for ( 1 ®-~® 5 ) $\C{// for ( typeof(1) i = 5; i > 0; i -= 1 )}$ 1182 1150 \end{cfa} 1183 1151 \item 1184 1152 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. 1185 1153 \begin{cfa} 1186 for ( 1 ®-~=® 5 ) $\C{// for ( typeof(1) i = 5; i >= 0; i -= 1 )}$1154 for ( 1 ®-~=® 5 ) $\C{// for ( typeof(1) i = 5; i >= 0; i -= 1 )}$ 1187 1155 \end{cfa} 1188 1156 \item 1189 1157 ©@© means put nothing in this field. 1190 1158 \begin{cfa} 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 */} )}$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 */} )}$ 1194 1162 \end{cfa} 1195 1163 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. … … 1198 1166 ©:© means low another index. 1199 1167 \begin{cfa} 1200 for ( i; 5 ®:® j; 2 ~ 12 ~ 3 ) $\C{// for ( typeof(i) i = 1, j = 2; i < 5 \&\& j < 12; i += 1, j += 3 )}$1168 for ( i; 5 ®:® j; 2 ~ 12 ~ 3 ) $\C{// for ( typeof(i) i = 1, j = 2; i < 5 \&\& j < 12; i += 1, j += 3 )}$ 1201 1169 \end{cfa} 1202 1170 \end{itemize} 1203 1171 \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): 1204 1172 \begin{cfa} 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!}}}$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}$ 1208 1176 \end{cfa} 1209 1177 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. … … 1222 1190 1223 1191 \begin{figure} 1192 \centering 1224 1193 \begin{lrbox}{\myboxA} 1225 \begin{cfa}[tabsize= 4]1194 \begin{cfa}[tabsize=3] 1226 1195 ®Compound:® { 1227 1196 ®Try:® try { … … 1253 1222 1254 1223 \begin{lrbox}{\myboxB} 1255 \begin{cfa}[tabsize= 4]1224 \begin{cfa}[tabsize=3] 1256 1225 { 1257 1226 … … 1282 1251 \end{lrbox} 1283 1252 1284 \subfloat[ C]{\label{f:CFAFibonacciGen}\usebox\myboxB}1253 \subfloat[\CFA]{\label{f:CFibonacci}\usebox\myboxA} 1285 1254 \hspace{3pt} 1286 1255 \vrule 1287 1256 \hspace{3pt} 1288 \subfloat[ \CFA]{\label{f:CFibonacci}\usebox\myboxA}1257 \subfloat[C]{\label{f:CFAFibonacciGen}\usebox\myboxB} 1289 1258 \caption{Multi-level Exit} 1290 1259 \label{f:MultiLevelExit} … … 1320 1289 int a[10]; 1321 1290 \end{cfa} 1322 \begin{tabular}{@{}l @{\hspace{3em}}l@{\hspace{3em}}l@{}}1291 \begin{tabular}{@{}lll@{}} 1323 1292 \begin{cfa} 1324 1293 … … 1361 1330 Grouping heterogeneous data into an \newterm{aggregate} (structure/union) is a common programming practice, and aggregates may be nested: 1362 1331 \begin{cfa} 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; 1332 struct Person { $\C{// aggregate}$ 1333 struct Name { char first[20], last[20]; } name $\C{// nesting}$ 1334 struct Address { ... } address $\C{// nesting}$ 1370 1335 int sex; 1371 1336 }; … … 1374 1339 \begin{cfa} 1375 1340 Person p 1376 ®p.®name; ®p.®address; ®p.®sex; $\C{// access containing fields}$1341 ®p.®name; ®p.®address; ®p.®sex; $\C{// access containing fields}$ 1377 1342 \end{cfa} 1378 1343 which extends to multiple levels of qualification for nested aggregates and multiple aggregates. … … 1389 1354 \begin{cfa} 1390 1355 struct S { 1391 struct $\R{\LstCommentStyle{/* unnamed */}}$ { int g, h; } __attribute__(( aligned(64) ));1356 struct $\R{\LstCommentStyle{/* unnamed */}}$ { int g, h; } __attribute__(( aligned(64) )); 1392 1357 int tag; 1393 union $\R{\LstCommentStyle{/* unnamed */}}$ {1358 union $\R{\LstCommentStyle{/* unnamed */}}$ { 1394 1359 struct { char c1, c2; } __attribute__(( aligned(128) )); 1395 1360 struct { int i1, i2; }; … … 1405 1370 struct S { 1406 1371 char ®c®; int ®i®; double ®d®; 1407 void f( /* S * this */ ) { $\C{// implicit ``this'' parameter}$1408 ®c®; ®i®; ®d®; $\C{// this->c; this->i; this->d;}$1372 void f( /* S * this */ ) { $\C{// implicit ``this'' parameter}$ 1373 ®c®; ®i®; ®d®; $\C{// this->c; this->i; this->d;}$ 1409 1374 } 1410 1375 } … … 1414 1379 \begin{cfa} 1415 1380 struct T { 1416 char ®m®; int ®i®; double ®n®; $\C{// derived class variables}$1381 char ®m®; int ®i®; double ®n®; $\C{// derived class variables}$ 1417 1382 }; 1418 1383 struct S : public T { 1419 char ®c®; int ®i®; double ®d®; $\C{// class variables}$1384 char ®c®; int ®i®; double ®d®; $\C{// class variables}$ 1420 1385 void g( double ®d®, T & t ) { 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}$1386 d; ®t®.m; ®t®.i; ®t®.n; $\C{// function parameter}$ 1387 c; i; ®this->®d; ®S::®d; $\C{// class S variables}$ 1388 m; ®T::®i; n; $\C{// class T variables}$ 1424 1389 } 1425 1390 }; … … 1431 1396 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. 1432 1397 \begin{cfa} 1433 void f( S & this ) ®with ( this )® { $\C{// with statement}$1434 ®c®; ®i®; ®d®; $\C{// this.c, this.i, this.d}$1398 void f( S & this ) ®with ( this )® { $\C{// with statement}$ 1399 ®c®; ®i®; ®d®; $\C{// this.c, this.i, this.d}$ 1435 1400 } 1436 1401 \end{cfa} 1437 1402 with the generality of opening multiple aggregate-parameters: 1438 1403 \begin{cfa} 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}$1404 void g( S & s, T & t ) ®with ( s, t )® { $\C{// multiple aggregate parameters}$ 1405 c; ®s.®i; d; $\C{// s.c, s.i, s.d}$ 1406 m; ®t.®i; n; $\C{// t.m, t.i, t.n}$ 1442 1407 } 1443 1408 \end{cfa} … … 1462 1427 struct R { int ®i®; int j; double ®m®; } r, w; 1463 1428 with ( r, q ) { 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}$1429 j + k; $\C{// unambiguous, r.j + q.k}$ 1430 m = 5.0; $\C{// unambiguous, q.m = 5.0}$ 1431 m = 1; $\C{// unambiguous, r.m = 1}$ 1432 int a = m; $\C{// unambiguous, a = r.i }$ 1433 double b = m; $\C{// unambiguous, b = q.m}$ 1434 int c = r.i + q.i; $\C{// disambiguate with qualification}$ 1435 (double)m; $\C{// disambiguate with cast}$ 1471 1436 } 1472 1437 \end{cfa} … … 1476 1441 \begin{cfa} 1477 1442 with ( r ) { 1478 i; $\C{// unambiguous, r.i}$1443 i; $\C{// unambiguous, r.i}$ 1479 1444 with ( q ) { 1480 i; $\C{// unambiguous, q.i}$1445 i; $\C{// unambiguous, q.i}$ 1481 1446 } 1482 1447 } … … 1485 1450 A cast can also be used to disambiguate among overload variables in a ©with© \emph{expression}: 1486 1451 \begin{cfa} 1487 with ( w ) { ... } $\C{// ambiguous, same name and no context}$1488 with ( (Q)w ) { ... } $\C{// unambiguous, cast}$1452 with ( w ) { ... } $\C{// ambiguous, same name and no context}$ 1453 with ( (Q)w ) { ... } $\C{// unambiguous, cast}$ 1489 1454 \end{cfa} 1490 1455 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©. … … 1493 1458 \begin{cfa} 1494 1459 void f( S & s, char c ) with ( s ) { 1495 ®s.c = c;® i = 3; d = 5.5; $\C{// initialize fields}$1460 ®s.c = c;® i = 3; d = 5.5; $\C{// initialize fields}$ 1496 1461 } 1497 1462 \end{cfa} … … 1499 1464 To solve this problem, parameters \emph{not} explicitly opened are treated like an initialized aggregate: 1500 1465 \begin{cfa} 1501 struct Params { $\C{// s explicitly opened so S \& s elided}$1466 struct Params { $\C{// s explicitly opened so S \& s elided}$ 1502 1467 char c; 1503 1468 } params; … … 1518 1483 Transfer of control can be local, within a routine, or non-local, among routines. 1519 1484 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 scope1525 ... // exception fields1526 );1527 try {1528 ...1529 if ( ... ) ®throwResume® ®ExceptionInst®( E, /* intialization */ );1530 if ( ... ) ®throw® ®ExceptionInst®( E, /* intialization */ );1531 ...1532 } ®catchResume®( E * ) { // must be pointer1533 ...1534 } catch( E * ) {1535 ...1536 }1537 \end{cfa}1538 1539 1485 \begin{cfa} 1540 1486 exception_t E {}; $\C{// exception type}$ … … 1545 1491 try { 1546 1492 f(...); 1547 } catch( E e ; $boolean-predicate$ ) { $\C{// termination handler}$1493 } catch( E e ; $boolean-predicate$ ) { $\C{// termination handler}$ 1548 1494 // recover and continue 1549 1495 } catchResume( E e ; $boolean-predicate$ ) { $\C{// resumption handler}$ … … 1557 1503 The ©catch© and ©catchResume© handlers may appear in any oder. 1558 1504 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 reference1570 ...1571 } catch( E & ) {1572 ...1573 }1574 }1575 \end{cfa}1576 1505 1577 1506 … … 1639 1568 \begin{cquote} 1640 1569 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1641 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1570 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1571 \begin{cfa}[moredelim={**[is][\color{blue}]{\#}{\#}}] 1572 #[5] *# ®int® x1; 1573 #* [5]# ®int® x2; 1574 #[* [5] int]# f®( int p )®; 1575 \end{cfa} 1576 & 1642 1577 \begin{cfa}[moredelim={**[is][\color{blue}]{\#}{\#}}] 1643 1578 ®int® #*# x1 #[5]#; 1644 1579 ®int® #(*#x2#)[5]#; 1645 1580 #int (*#f®( int p )®#)[5]#; 1646 \end{cfa}1647 &1648 \begin{cfa}[moredelim={**[is][\color{blue}]{\#}{\#}}]1649 #[5] *# ®int® x1;1650 #* [5]# ®int® x2;1651 #[* [5] int]# f®( int p )®;1652 1581 \end{cfa} 1653 1582 \end{tabular} … … 1659 1588 \begin{cquote} 1660 1589 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1661 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1590 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1591 \begin{cfa} 1592 ®*® int x, y; 1593 \end{cfa} 1594 & 1662 1595 \begin{cfa} 1663 1596 int ®*®x, ®*®y; 1664 \end{cfa}1665 &1666 \begin{cfa}1667 ®*® int x, y;1668 1597 \end{cfa} 1669 1598 \end{tabular} … … 1672 1601 \begin{cquote} 1673 1602 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 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 & 1603 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1680 1604 \begin{cfa} 1681 1605 ®*® int x; 1682 1606 int y; 1607 \end{cfa} 1608 & 1609 \begin{cfa} 1610 int ®*®x, y; 1611 1683 1612 \end{cfa} 1684 1613 \end{tabular} … … 1688 1617 \begin{cquote} 1689 1618 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}} 1690 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}} \\ 1619 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{C}} \\ 1620 \begin{cfa} 1621 [ 5 ] int z; 1622 [ 5 ] * char w; 1623 * [ 5 ] double v; 1624 struct s { 1625 int f0:3; 1626 * int f1; 1627 [ 5 ] * int f2; 1628 }; 1629 \end{cfa} 1630 & 1691 1631 \begin{cfa} 1692 1632 int z[ 5 ]; … … 1701 1641 & 1702 1642 \begin{cfa} 1703 [ 5 ] int z;1704 [ 5 ] * char w;1705 * [ 5 ] double v;1706 struct s {1707 int f0:3;1708 * int f1;1709 [ 5 ] * int f2;1710 };1711 \end{cfa}1712 &1713 \begin{cfa}1714 1643 // array of 5 integers 1715 1644 // array of 5 pointers to char … … 1727 1656 \begin{cquote} 1728 1657 \begin{tabular}{@{}l@{\hspace{1em}}l@{\hspace{1em}}l@{}} 1729 \multicolumn{1}{c@{\hspace{1em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{1em}}}{\textbf{\CFA}} \\ 1658 \multicolumn{1}{c@{\hspace{1em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{1em}}}{\textbf{C}} \\ 1659 \begin{cfa} 1660 const * const int x; 1661 const * [ 5 ] const int y; 1662 \end{cfa} 1663 & 1730 1664 \begin{cfa} 1731 1665 int const * const x; 1732 1666 const int (* const y)[ 5 ] 1733 \end{cfa}1734 &1735 \begin{cfa}1736 const * const int x;1737 const * [ 5 ] const int y;1738 1667 \end{cfa} 1739 1668 & … … 1748 1677 \begin{cquote} 1749 1678 \begin{tabular}{@{}l@{\hspace{3em}}l@{\hspace{2em}}l@{}} 1750 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{\CFA}} \\ 1679 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c@{\hspace{2em}}}{\textbf{C}} \\ 1680 \begin{cfa} 1681 extern [ 5 ] int x; 1682 static * const int y; 1683 \end{cfa} 1684 & 1751 1685 \begin{cfa} 1752 1686 int extern x[ 5 ]; 1753 1687 const int static * y; 1754 \end{cfa}1755 &1756 \begin{cfa}1757 extern [ 5 ] int x;1758 static * const int y;1759 1688 \end{cfa} 1760 1689 & … … 1769 1698 \begin{cquote} 1770 1699 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 1771 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1700 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1701 \begin{cfa} 1702 y = (* int)x; 1703 i = sizeof([ 5 ] * int); 1704 \end{cfa} 1705 & 1772 1706 \begin{cfa} 1773 1707 y = (int *)x; 1774 1708 i = sizeof(int * [ 5 ]); 1775 \end{cfa}1776 &1777 \begin{cfa}1778 y = (* int)x;1779 i = sizeof([ 5 ] * int);1780 1709 \end{cfa} 1781 1710 \end{tabular} … … 1972 1901 \begin{cquote} 1973 1902 \begin{tabular}{@{}l@{\hspace{3em}}l@{}} 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 & 1903 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1980 1904 \begin{cfa} 1981 1905 ®const® * ®const® * const int ccp; 1982 1906 ®const® & ®const® & const int ccr; 1907 \end{cfa} 1908 & 1909 \begin{cfa} 1910 const int * ®const® * ®const® ccp; 1911 1983 1912 \end{cfa} 1984 1913 \end{tabular} … … 2141 2070 \begin{cfa} 2142 2071 int x, &r = ®x®, f( int & p ); $\C{// lvalue variable (int) convert to reference (int \&)}$ 2143 f( ®x® ); $\C{// lvalue variable (int) convert to reference (int \&)} \CRT$2072 f( ®x® ); $\C{// lvalue variable (int) convert to reference (int \&)}$ 2144 2073 \end{cfa} 2145 2074 Conversion can restrict a type, where ©cv1© $\le$ ©cv2©, \eg passing an ©int© to a ©const volatile int &©, which has low cost. … … 8701 8630 \begin{cquote} 8702 8631 \begin{tabular}{@{}l@{\hspace{\parindentlnth}}|@{\hspace{\parindentlnth}}l@{}} 8703 \multicolumn{1}{@{}c|@{\hspace{\parindentlnth}}}{\textbf{ C}} & \multicolumn{1}{@{\hspace{\parindentlnth}}c@{}}{\textbf{\CFA}} \\8632 \multicolumn{1}{@{}c|@{\hspace{\parindentlnth}}}{\textbf{\CFA}} & \multicolumn{1}{@{\hspace{\parindentlnth}}c@{}}{\textbf{C}} \\ 8704 8633 \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 & 8705 8648 \begin{cfa} 8706 8649 #include <gmp.h>$\indexc{gmp.h}$ … … 8713 8656 ®mpz_mul_ui®( fact, fact, i ); 8714 8657 ®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;8729 8658 } 8730 8659 }
Note:
See TracChangeset
for help on using the changeset viewer.