# Changeset ba80f99

Ignore:
Timestamp:
Sep 3, 2018, 8:35:55 AM (3 years ago)
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer
Children:
245a92c
Parents:
e255e69
Message:

add material on extened for-control, fix index entries

File:
1 edited

### Legend:

Unmodified
 re255e69 %% Created On       : Wed Apr  6 14:53:29 2016 %% Last Modified By : Peter A. Buhr %% Last Modified On : Thu Jul 26 17:29:05 2018 %% Update Count     : 3366 %% Last Modified On : Fri Aug 31 07:54:50 2018 %% Update Count     : 3396 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Even with all its problems, C continues to be popular because it allows writing software at virtually any level in a computer system without restriction. For system programming, where direct access to hardware, storage management, and real-time issues are a requirement, C is usually the only language of choice. The TIOBE index~\cite{TIOBE} for July 2018 ranks the top 5 most \emph{popular} programming languages as: \Index*{Java} 16\%, C 14\%, \Index*[C++]{\CC{}} 7.5\%, Python 6\%, Visual Basic 4\% = 47.5\%, where the next 50 languages are less than 4\% each, with a long tail. The TIOBE index~\cite{TIOBE} for July 2018 ranks the top five most \emph{popular} programming languages as \Index*{Java} 16\%, C 14\%, \Index*[C++]{\CC{}} 7.5\%, Python 6\%, Visual Basic 4\% = 47.5\%, where the next 50 languages are less than 4\% each, with a long tail. The top 3 rankings over the past 30 years are: \begin{center} The 2011 C standard plus GNU extensions. \item \Indexc[deletekeywords=inline]{-fgnu89-inline}\index{compilation option!-fgnu89-inline@{\lstinline[deletekeywords=inline]@-fgnu89-inline@}} \Indexc[deletekeywords=inline]{-fgnu89-inline}\index{compilation option!-fgnu89-inline@{\lstinline[deletekeywords=inline]$-fgnu89-inline$}} Use the traditional GNU semantics for inline routines in C11 mode, which allows inline routines in header files. \end{description} #endif ®#include_next                                       §\C{// must have internal check for multiple expansion}§ ®#include_next                       §\C{// must have internal check for multiple expansion}§ ® #if defined( with ) && defined( __CFA_BFD_H__ ) §\C{// reset only if set}§ C, \CC, and Java (and many other programming languages) have no exponentiation operator\index{exponentiation!operator}\index{operator!exponentiation}, \ie $x^y$, and instead use a routine, like \Indexc{pow}, to perform the exponentiation operation. \CFA extends the basic operators with the exponentiation operator ©?\?©\index{?\\?@\lstinline@?\?@} and ©?\=?©\index{?\\=?@\lstinline@?\=?@}, as in, ©x \ y© and ©x \= y©, which means $x^y$ and $x \leftarrow x^y$. \CFA extends the basic operators with the exponentiation operator ©?\?©\index{?\\?@©?\?©} and ©?\=?©\index{?\\=?@©\=?©}, as in, ©x \ y© and ©x \= y©, which means $x^y$ and $x \leftarrow x^y$. The priority of the exponentiation operator is between the cast and multiplicative operators, so that ©w * (int)x \ (int)y * z© is parenthesized as ©((w * (((int)x) \ ((int)y))) * z)©. 256 64 -64 0.015625 -0.015625 18.3791736799526 0.264715-1.1922i \end{cfa} Parenthesis are necessary for the complex constants or the expression is parsed as ©1.0f+(2.0fi \ 3.0f)+2.0fi©. Parenthesis are necessary for complex constants or the expression is parsed as ©1.0f+®(®2.0fi \ 3.0f®)®+2.0fi©. The exponentiation operator is available for all the basic types, but for user-defined types, only the integral-computation versions are available. For returning an integral value, the user type ©T© must define multiplication, ©*©, and one, ©1©; %\subsection{\texorpdfstring{\protect\lstinline@if@ Statement}{if Statement}} \subsection{\texorpdfstring{\LstKeywordStyle{if} Statement}{if Statement}} The ©if© expression allows declarations, similar to ©for© declaration expression: \begin{cfa} if ( int x = f() ) ...                                          §\C{// x != 0}§ if ( int x = f(), y = g() ) ...                         §\C{// x != 0 \&\& y != 0}§ if ( int x = f(), y = g(); ®x < y® ) ...        §\C{// relational expression}§ \end{cfa} Unless a relational expression is specified, each variable is compared not equal to 0, which is the standard semantics for the ©if© expression, and the results are combined using the logical ©&&© operator.\footnote{\CC only provides a single declaration always compared not equal to 0.} %\subsection{\texorpdfstring{\protect\lstinline@if@/\protect\lstinline@while@ Statement}{if Statement}} \subsection{\texorpdfstring{\LstKeywordStyle{if}/\LstKeywordStyle{while} Statement}{if/while Statement}} The ©if©/©while© expression allows declarations, similar to ©for© declaration expression. (Does not make sense for ©do©-©while©.) \begin{cfa} if ( ®int x = f()® ) ...                                        §\C{// x != 0}§ if ( ®int x = f(), y = g()® ) ...                       §\C{// x != 0 \&\& y != 0}§ if ( ®int x = f(), y = g(); x < y® ) ...        §\C{// relational expression}§ if ( ®struct S { int i; } x = { f() }; x.i < 4® ) §\C{// relational expression}§ while ( ®int x = f()® ) ...                                     §\C{// x != 0}§ while ( ®int x = f(), y = g()® ) ...            §\C{// x != 0 \&\& y != 0}§ while ( ®int x = f(), y = g(); x < y® ) ... §\C{// relational expression}§ while ( ®struct S { int i; } x = { f() }; x.i < 4® ) ... §\C{// relational expression}§ \end{cfa} Unless a relational expression is specified, each variable is compared not equal to 0, which is the standard semantics for the ©if©/©while© expression, and the results are combined using the logical ©&&© operator.\footnote{\CC only provides a single declaration always compared not equal to 0.} The scope of the declaration(s) is local to the @if@ statement but exist within both the then'' and else'' clauses. %\subsection{\texorpdfstring{\protect\lstinline@for@ Statement}{for Statement}} \subsection{\texorpdfstring{\LstKeywordStyle{for} Statement}{for Statement}} The ©for©/©while©/©do-while© loop-control allows empty or simplified ranges. An empty conditional implies ©1©. The up-to range ©~©\index{~@©~©} means exclusive range [M,N); the up-to range ©~=©\index{~=@©~=©} means inclusive range [M,N]. The down-to range ©-~©\index{-~@©-~©} means exclusive range [N,M); the down-to range ©-~=©\index{-~=@©-~=©} means inclusive range [N,M]. ©0© is the implicit start value; ©1© is the implicit increment value for an up-to range and ©-1© for an implicit down-to range. The loop index is polymorphic in the type of the start value or comparison value when start is implicitly ©0©. \begin{cquote} \begin{tabular}{@{}ll|l@{}} \multicolumn{2}{c|}{for control} & \multicolumn{1}{c}{output} \\ \hline \begin{cfa} while ®()® { sout | "empty"; break; } do { sout | "empty"; break; } while ®()®; for ®()® { sout | "empty"; break; } for ( ®0® ) { sout | "A"; } for ( ®1® ) { sout | "A"; } for ( ®10® ) { sout | "A"; } for ( ®1 ~= 10 ~ 2® ) { sout | "B"; } for ( ®10 -~= 1 ~ -2® ) { sout | "C"; } for ( ®0.5 ~ 5.5® ) { sout | "D"; } for ( ®5.5 -~ 0.5® ) { sout | "E"; } for ( ®i; 10® ) { sout | i; } for ( ®i; 1 ~= 10 ~ 2® ) { sout | i; } for ( ®i; 10 -~= 1 ~ -2® ) { sout | i; } for ( ®i; 0.5 ~ 5.5® ) { sout | i; } for ( ®i; 5.5 -~ 0.5® ) { sout | i; } for ( ®ui; 2u ~= 10u ~ 2u® ) { sout | ui; } for ( ®ui; 10u -~= 2u ~ -2u® ) { sout | ui; } int start = 3, comp = 10, inc = 2; for ( ®i; start ~ comp ~ inc + 1® ) { sout | i; } \end{cfa} & \begin{cfa} sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; sout | endl; \end{cfa} & \begin{cfa} empty empty empty A A A A A A A A A A A B B B B B C C C C C D D D D D E E E E E 0 1 2 3 4 5 6 7 8 9 1 3 5 7 9 10 8 6 4 2 0.5 1.5 2.5 3.5 4.5 5.5 4.5 3.5 2.5 1.5 2 4 6 8 10 10 8 6 4 2 3 6 9 \end{cfa} \end{tabular} \end{cquote} % for ()  => for ( ;; ) % for ( 10 - t ) => for ( typeof(10 - t) ? = 0 ; ? < 10 - t; ? += 1 ) // using 0 and 1 % for ( i ; 10 - t ) => for ( typeof(10 - t) i = 0 ; i < 10 - t; i += 1 ) // using 0 and 1 % for ( T i ; 10 - t ) => for ( T i = 0 ; i < 10 - t; i += 1 ) // using 0 and 1 % for ( 3~9 ) => for ( int ? = 3 ; ? < 9; ? += 1 ) // using 1 % for ( i ; 3~9 ) => for ( int i = 3 ; i < 9; i += 1 ) // using 1 % for ( T i ; 3~9 ) => for ( T i = 3 ; i < 9; i += 1 ) // using 1 %\subsection{\texorpdfstring{Labelled \protect\lstinline@continue@ / \protect\lstinline@break@}{Labelled continue / break}} \subsection{\texorpdfstring{Labelled \LstKeywordStyle{continue} / \LstKeywordStyle{break} Statement}{Labelled continue / break Statement}} While C provides ©continue© and ©break© statements for altering control flow, both are restricted to one level of nesting for a particular control structure. Unfortunately, this restriction forces programmers to use \Indexc{goto} to achieve the equivalent control-flow for more than one level of nesting. To prevent having to switch to the ©goto©, \CFA extends the \Indexc{continue}\index{continue@\lstinline@continue@!labelled}\index{labelled!continue@©continue©} and \Indexc{break}\index{break@\lstinline@break@!labelled}\index{labelled!break@©break©} with a target label to support static multi-level exit\index{multi-level exit}\index{static multi-level exit}~\cite{Buhr85}, as in Java. To prevent having to switch to the ©goto©, \CFA extends the \Indexc{continue}\index{continue@©continue©!labelled}\index{labelled!continue@©continue©} and \Indexc{break}\index{break@©break©!labelled}\index{labelled!break@©break©} with a target label to support static multi-level exit\index{multi-level exit}\index{static multi-level exit}~\cite{Buhr85}, as in Java. For both ©continue© and ©break©, the target label must be directly associated with a ©for©, ©while© or ©do© statement; for ©break©, the target label can also be associated with a ©switch©, ©if© or compound (©{}©) statement. \end{figure} Both labelled ©continue© and ©break© are a ©goto©\index{goto@\lstinline@goto@!restricted} restricted in the following ways: Both labelled ©continue© and ©break© are a ©goto©\index{goto@©goto©!restricted} restricted in the following ways: \begin{itemize} \item