Changes in / [a0b3e32:35b06a8]


Ignore:
Files:
25 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • doc/LaTeXmacros/common.tex

    ra0b3e32 r35b06a8  
    1111%% Created On       : Sat Apr  9 10:06:17 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Sun Jun 18 20:32:32 2017
    14 %% Update Count     : 319
     13%% Last Modified On : Thu Jul 13 11:44:59 2017
     14%% Update Count     : 335
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    3636% Names used in the document.
    3737
    38 \newcommand{\CFAIcon}{\textrm{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name
     38\newcommand{\CFAIcon}{\textsf{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}\xspace} % Cforall symbolic name
    3939\newcommand{\CFA}{\protect\CFAIcon} % safe for section/caption
    4040\newcommand{\CFL}{\textrm{Cforall}\xspace} % Cforall symbolic name
     
    5555\setlength{\parindentlnth}{\parindent}
    5656
     57\newcommand{\LstKeywordStyle}[1]{{\lst@basicstyle{\lst@keywordstyle{#1}}}}
     58\newcommand{\LstCommentStyle}[1]{{\lst@basicstyle{\lst@commentstyle{#1}}}}
     59
    5760\newlength{\gcolumnposn}                                % temporary hack because lstlisting does not handle tabs correctly
    5861\newlength{\columnposn}
    5962\setlength{\gcolumnposn}{2.5in}
    6063\setlength{\columnposn}{\gcolumnposn}
    61 \newcommand{\C}[2][\@empty]{\ifx#1\@empty\else\global\setlength{\columnposn}{#1}\global\columnposn=\columnposn\fi\hfill\makebox[\textwidth-\columnposn][l]{\lst@commentstyle{#2}}}
     64\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}}}}
    6265\newcommand{\CRT}{\global\columnposn=\gcolumnposn}
    6366
     
    231234basicstyle=\linespread{0.9}\sf,                                                 % reduce line spacing and use sanserif font
    232235stringstyle=\tt,                                                                                % use typewriter font
    233 tabsize=4,                                                                                              % 4 space tabbing
     236tabsize=6,                                                                                              % N space tabbing
    234237xleftmargin=\parindentlnth,                                                             % indent code to paragraph indentation
    235238extendedchars=true,                                                                             % allow ASCII characters in the range 128-255
  • doc/LaTeXmacros/lstlang.sty

    ra0b3e32 r35b06a8  
    88%% Created On       : Sat May 13 16:34:42 2017
    99%% Last Modified By : Peter A. Buhr
    10 %% Last Modified On : Thu Jun 22 07:40:31 2017
    11 %% Update Count     : 10
     10%% Last Modified On : Wed Jul 12 22:42:09 2017
     11%% Update Count     : 12
    1212%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1313
     
    112112                finally, forall, ftype, _Generic, _Imaginary, inline, __label__, lvalue, _Noreturn, one_t,
    113113                otype, restrict, _Static_assert, throw, throwResume, trait, try, ttype, typeof, __typeof,
    114                 __typeof__, zero_t},
     114                __typeof__, with, zero_t},
    115115        morekeywords=[2]{
    116116                _Atomic, coroutine, is_coroutine, is_monitor, is_thread, monitor, mutex, nomutex,
     
    118118        moredirectives={defined,include_next}%
    119119}
     120
     121% C++ programming language
     122\lstdefinelanguage{C++}[ANSI]{C++}{}
    120123
    121124% uC++ programming language, based on ANSI C++
  • doc/bibliography/cfa.bib

    ra0b3e32 r35b06a8  
    22732273@manual{JavaScript,
    22742274    keywords    = {JavaScript},
    2275     contributer = {pabuhr},
     2275    contributer = {pabuhr@plg},
    22762276    title       = {ECMAScript 2015 Language Specification {JavaScript}},
    22772277    organization= {ECAM International},
     
    24462446@manual{Erlang,
    24472447    keywords    = {Erlang},
    2448     contributer = {pabuhr},
     2448    contributer = {pabuhr@plg},
    24492449    title       = {Erlang Reference Manual User's Guide, Vertion 7.0},
    24502450    organization= {Erlang/OTP System Documentation},
     
    27712771    publisher   = {ACM},
    27722772    address     = {New York, NY, USA},
     2773}
     2774
     2775@article{Yang95,
     2776    keywords    = {software solutions, N-thread, mutual exclusions},
     2777    contributer = {pabuhr@plg},
     2778    author      = {Jae-Heon Yang and James H. Anderson},
     2779    title       = {A Fast, Scalable Mutual Exclusion Algorithm},
     2780    journal     = {Distributed Computing},
     2781    publisher   = {Springer-Verlag},
     2782    volume      = {9},
     2783    number      = {1},
     2784    year        = {1995},
     2785    pages       = {51-60},
    27732786}
    27742787
     
    50525065    contributer = {pabuhr@plg},
    50535066    author      = {Kathleen Jensen and Niklaus Wirth},
    5054     title       = {{P}ascal User Manual and Report},
     5067    title       = {{P}ascal User Manual and Report, ISO Pascal Standard},
    50555068    publisher   = {Springer--Verlag},
    5056     year        = 1985,
    5057     edition     = {3rd},
    5058     note        = {Revised by Andrew B. Mickel and James F. Miner, ISO Pascal Standard}
     5069    year        = 1991,
     5070    edition     = {4th},
     5071    note        = {Revised by Andrew B. Mickel and James F. Miner}
    50595072}
    50605073
  • doc/user/Makefile

    ra0b3e32 r35b06a8  
    11## Define the appropriate configuration variables.
    22
    3 TeXLIB = .:../LaTeXmacros:../LaTeXmacros/listings:../LaTeXmacros/enumitem:../bibliography/:
     3TeXLIB = .:../LaTeXmacros:../bibliography/:
    44LaTeX  = TEXINPUTS=${TeXLIB} && export TEXINPUTS && latex -halt-on-error
    55BibTeX = BIBINPUTS=${TeXLIB} && export BIBINPUTS && bibtex
  • doc/user/user.tex

    ra0b3e32 r35b06a8  
    1111%% Created On       : Wed Apr  6 14:53:29 2016
    1212%% Last Modified By : Peter A. Buhr
    13 %% Last Modified On : Fri Jul  7 10:36:39 2017
    14 %% Update Count     : 2547
     13%% Last Modified On : Thu Jul 13 11:44:57 2017
     14%% Update Count     : 2690
    1515%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1616
     
    5757\CFAStyle                                                                                               % use default CFA format-style
    5858
     59\lstnewenvironment{C++}[1][]
     60{\lstset{language=C++,moredelim=**[is][\protect\color{red}]{®}{®}#1}}
     61{}
     62
    5963% inline code ©...© (copyright symbol) emacs: C-q M-)
    6064% red highlighting ®...® (registered trademark symbol) emacs: C-q M-.
     
    137141
    138142\CFA{}\index{cforall@\CFA}\footnote{Pronounced ``\Index*{C-for-all}'', and written \CFA, CFA, or \CFL.} is a modern general-purpose programming-language, designed as an evolutionary step forward for the C programming language.
    139 The syntax of the \CFA language builds from C, and should look immediately familiar to C/\Index*[C++]{\CC{}} programmers.
     143The syntax of \CFA builds from C and should look immediately familiar to C/\Index*[C++]{\CC{}} programmers.
    140144% Any language feature that is not described here can be assumed to be using the standard \Celeven syntax.
    141 \CFA adds many modern programming-language features that directly lead to increased \emph{\Index{safety}} and \emph{\Index{productivity}}, while maintaining interoperability with existing C programs and achieving C performance.
    142 Like C, \CFA is a statically typed, procedural language with a low-overhead runtime, meaning there is no global \Index{garbage-collection}, but \Index{regional garbage-collection}\index{garbage-collection!regional} is possible.
     145\CFA adds many modern programming-language features that directly lead to increased \emph{\Index{safety}} and \emph{\Index{productivity}}, while maintaining interoperability with existing C programs and achieving similar performance.
     146Like C, \CFA is a statically typed, procedural (non-\Index{object-oriented}) language with a low-overhead runtime, meaning there is no global \Index{garbage-collection}, but \Index{regional garbage-collection}\index{garbage-collection!regional} is possible.
    143147The primary new features include parametric-polymorphic routines and types, exceptions, concurrency, and modules.
    144148
    145 One of the main design philosophies of \CFA is to ``describe not prescribe'', which means \CFA tries to provide a pathway from low-level C programming to high-level \CFA programming, but it does not force programmers to ``do the right thing''.
    146 Programmers can cautiously add \CFA extensions to their C programs in any order and at any time to incrementally move towards safer, higher-level programming features.
    147 A programmer is always free to reach back to C from \CFA for any reason, and in many cases, new \CFA features have a fallback to a C mechanism.
    148 There is no notion or requirement for rewriting a legacy C program in \CFA;
    149 instead, a programmer evolves an existing C program into \CFA by incrementally incorporating \CFA features.
    150 New programs can be written in \CFA using a combination of C and \CFA features.
    151 \Index*[C++]{\CC{}} had a similar goal 30 years ago, but currently has the disadvantages of multiple legacy design-choices that cannot be updated and active divergence of the language model from C, requiring significant effort and training to incrementally add \CC to a C-based project.
     149One of the main design philosophies of \CFA is to ``\Index{describe not prescribe}'', which means \CFA tries to provide a pathway from low-level C programming to high-level \CFA programming, but it does not force programmers to ``do the right thing''.
     150Programmers can cautiously add \CFA extensions to their C programs in any order and at any time to incrementally move towards safer, higher-level programming.
     151A programmer is always free to reach back to C from \CFA, for any reason, and in many cases, new \CFA features can be locally switched back to there C counterpart.
     152There is no notion or requirement for \emph{rewriting} a legacy C program in \CFA;
     153instead, a programmer evolves a legacy program into \CFA by incrementally incorporating \CFA features.
     154As well, new programs can be written in \CFA using a combination of C and \CFA features.
     155
     156\Index*[C++]{\CC{}} had a similar goal 30 years ago, allowing object-oriented programming to be incrementally added to C.
     157However, \CC currently has the disadvantages of a strong object-oriented bias, multiple legacy design-choices that cannot be updated, and active divergence of the language model from C, all of which requires significant effort and training to incrementally add \CC to a C-based project.
    152158In contrast, \CFA has 30 years of hindsight and a clean starting point.
    153159
     
    156162\begin{quote2}
    157163\begin{tabular}{@{}l@{\hspace{1.5em}}l@{\hspace{1.5em}}l@{}}
    158 \multicolumn{1}{c@{\hspace{1.5em}}}{\textbf{\CFA}}      & \multicolumn{1}{c}{\textbf{C}}        & \multicolumn{1}{c}{\textbf{\CC}}      \\
    159 \begin{cfa}
    160 #include <fstream>§\indexc{fstream}§
    161 
    162 int main( void ) {
    163         int x = 0, y = 1, z = 2;
    164         ®sout | x | y | z | endl;®
    165 }
    166 \end{cfa}
    167 &
    168 \begin{lstlisting}
     164\multicolumn{1}{c@{\hspace{1.5em}}}{\textbf{C}} & \multicolumn{1}{c}{\textbf{\CFA}}     & \multicolumn{1}{c}{\textbf{\CC}}      \\
     165\begin{cfa}
    169166#include <stdio.h>§\indexc{stdio.h}§
    170167
     
    173170        ®printf( "%d %d %d\n", x, y, z );®
    174171}
    175 \end{lstlisting}
     172\end{cfa}
    176173&
    177 \begin{lstlisting}
     174\begin{cfa}
     175#include <fstream>§\indexc{fstream}§
     176
     177int main( void ) {
     178        int x = 0, y = 1, z = 2;
     179        ®sout | x | y | z | endl;®§\indexc{sout}§
     180}
     181\end{cfa}
     182&
     183\begin{cfa}
    178184#include <iostream>§\indexc{iostream}§
    179185using namespace std;
     
    182188        ®cout<<x<<" "<<y<<" "<<z<<endl;®
    183189}
    184 \end{lstlisting}
     190\end{cfa}
    185191\end{tabular}
    186192\end{quote2}
    187193While the \CFA I/O looks similar to the \Index*[C++]{\CC{}} output style, there are important differences, such as automatic spacing between variables as in \Index*{Python} (see~\VRef{s:IOLibrary}).
    188194
     195\subsection{Background}
     196
    189197This document is a programmer reference-manual for the \CFA programming language.
    190198The manual covers the core features of the language and runtime-system, with simple examples illustrating syntax and semantics of each feature.
    191199The manual does not teach programming, i.e., how to combine the new constructs to build complex programs.
    192 A reader should already have an intermediate knowledge of control flow, data structures, and concurrency issues to understand the ideas presented as well as some experience programming in C/\CC.
    193 Implementers may refer to the \CFA Programming Language Specification for details about the language syntax and semantics.
     200A reader should already have an intermediate knowledge of control flow, data structures, and concurrency issues to understand the ideas presented, as well as some experience programming in C/\CC.
     201Implementers should refer to the \CFA Programming Language Specification for details about the language syntax and semantics.
    194202Changes to the syntax and additional features are expected to be included in later revisions.
    195203
     
    200208This installation base and the programmers producing it represent a massive software-engineering investment spanning decades and likely to continue for decades more.
    201209Even with all its problems, C continues to be popular because it allows writing software at virtually any level in a computer system without restriction.
    202 For system programming, where direct access to hardware and dealing with real-time issues is a requirement, C is usually the language of choice.
     210For system programming, where direct access to hardware, storage management, and real-time issues are a requirement, C is usually the only language of choice.
    203211The TIOBE index~\cite{TIOBE} for March 2016 showed the following programming-language popularity: \Index*{Java} 20.5\%, C 14.5\%, \Index*[C++]{\CC{}} 6.7\%, \Csharp 4.3\%, \Index*{Python} 4.3\%, where the next 50 languages are less than 3\% each with a long tail.
    204212As well, for 30 years, C has been the number 1 and 2 most popular programming language:
     
    216224\end{center}
    217225Hence, C is still an extremely important programming language, with double the usage of \Index*[C++]{\CC{}}; in many cases, \CC is often used solely as a better C.
    218 Love it or hate it, C has been an important and influential part of computer science for 40 years and sit appeal is not diminishing.
    219 Unfortunately, C has too many problems and omissions to make it an acceptable programming language for modern needs.
    220 
    221 As stated, the goal of the \CFA project is to engineer modern language features into C in an evolutionary rather than revolutionary way.
     226Love it or hate it, C has been an important and influential part of computer science for 40 years and its appeal is not diminishing.
     227Unfortunately, C has many problems and omissions that make it an unacceptable programming language for modern needs.
     228
     229As stated, the goal of the \CFA project is to engineer modern language-features into C in an evolutionary rather than revolutionary way.
    222230\CC~\cite{C++14,C++} is an example of a similar project;
    223 however, it largely extended the language, and did not address many existing problems.\footnote{%
     231however, it largely extended the C language, and did not address most of C's existing problems.\footnote{%
    224232Two important existing problems addressed were changing the type of character literals from ©int© to ©char© and enumerator from ©int© to the type of its enumerators.}
    225 \Index*{Fortran}~\cite{Fortran08}, \Index*{Ada}~\cite{Ada12}, and \Index*{Cobol}~\cite{Cobol14} are examples of programming languages that took an evolutionary approach, where modern language features (\eg objects, concurrency) are added and problems fixed within the framework of the existing language.
     233\Index*{Fortran}~\cite{Fortran08}, \Index*{Ada}~\cite{Ada12}, and \Index*{Cobol}~\cite{Cobol14} are examples of programming languages that took an evolutionary approach, where modern language-features (\eg objects, concurrency) are added and problems fixed within the framework of the existing language.
    226234\Index*{Java}~\cite{Java8}, \Index*{Go}~\cite{Go}, \Index*{Rust}~\cite{Rust} and \Index*{D}~\cite{D} are examples of the revolutionary approach for modernizing C/\CC, resulting in a new language rather than an extension of the descendent.
    227 These languages have different syntax and semantics from C, and do not interoperate directly with C, largely because of garbage collection.
     235These languages have different syntax and semantics from C, do not interoperate directly with C, and are not systems languages because of restrictive memory-management or garbage collection.
    228236As a result, there is a significant learning curve to move to these languages, and C legacy-code must be rewritten.
    229 These costs can be prohibitive for many companies with a large software base in C/\CC, and a significant number of programmers requiring retraining to a new programming language.
    230 
    231 The result of this project is a language that is largely backwards compatible with \Index*[C11]{\Celeven{}}~\cite{C11}, but fixing some of the well known C problems and containing many modern language features.
     237These costs can be prohibitive for many companies with a large software-base in C/\CC, and a significant number of programmers require retraining to the new programming language.
     238
     239The result of this project is a language that is largely backwards compatible with \Index*[C11]{\Celeven{}}~\cite{C11}, but fixes many of the well known C problems while containing modern language-features.
    232240Without significant extension to the C programming language, it is becoming unable to cope with the needs of modern programming problems and programmers;
    233241as a result, it will fade into disuse.
    234242Considering the large body of existing C code and programmers, there is significant impetus to ensure C is transformed into a modern programming language.
    235 While \Index*[C11]{\Celeven{}} made a few simple extensions to the language, nothing was added to address existing problems in the language or to augment the language with modern language features.
    236 While some may argue that modern language features may make C complex and inefficient, it is clear a language without modern capabilities is insufficient for the advanced programming problems existing today.
     243While \Index*[C11]{\Celeven{}} made a few simple extensions to the language, nothing was added to address existing problems in the language or to augment the language with modern language-features.
     244While some may argue that modern language-features may make C complex and inefficient, it is clear a language without modern capabilities is insufficient for the advanced programming problems existing today.
    237245
    238246
    239247\section{History}
    240248
    241 The \CFA project started with \Index*{K-W C}~\cite{Buhr94a,Till89}, which extended C with new declaration syntax, multiple return values from routines, and extended assignment capabilities using the notion of tuples.
     249The \CFA project started with \Index*{K-W C}~\cite{Buhr94a,Till89}, which extended C with new declaration syntax, multiple return values from routines, and advanced assignment capabilities using the notion of tuples.
    242250(See~\cite{Werther96} for similar work in \Index*[C++]{\CC{}}.)
    243 A first \CFA implementation of these extensions was by Esteves~\cite{Esteves04}.
    244 The signature feature of \CFA is parametric-polymorphic functions~\cite{forceone:impl,Cormack90,Duggan96} with functions generalized using a ©forall© clause (giving the language its name):
     251The first \CFA implementation of these extensions was by Esteves~\cite{Esteves04}.
     252
     253The signature feature of \CFA is \Index{overload}able \Index{parametric-polymorphic} functions~\cite{forceone:impl,Cormack90,Duggan96} with functions generalized using a ©forall© clause (giving the language its name):
    245254\begin{lstlisting}
    246255®forall( otype T )® T identity( T val ) { return val; }
     
    250259\CFA{}\hspace{1pt}'s polymorphism was originally formalized by Ditchfiled~\cite{Ditchfield92}, and first implemented by Bilson~\cite{Bilson03}.
    251260However, at that time, there was little interesting in extending C, so work did not continue.
    252 As the saying goes, ``What goes around, comes around.'', and there is now renewed interest in the C programming language because of legacy code-bases, so the \CFA project has been restarted.
     261As the saying goes, ``\Index*{What goes around, comes around.}'', and there is now renewed interest in the C programming language because of legacy code-bases, so the \CFA project has been restarted.
    253262
    254263
     
    257266
    258267\CFA is designed to integrate directly with existing C programs and libraries.
    259 The most important feature of \Index{interoperability} is using the same \Index{calling convention}s, so there is no overhead to call existing C routines.
     268The most important feature of \Index{interoperability} is using the same \Index{calling convention}s, so there is no complex interface or overhead to call existing C routines.
    260269This feature allows \CFA programmers to take advantage of the existing panoply of C libraries to access thousands of external software features.
    261270Language developers often state that adequate \Index{library support} takes more work than designing and implementing the language itself.
    262271Fortunately, \CFA, like \Index*[C++]{\CC{}}, starts with immediate access to all exiting C libraries, and in many cases, can easily wrap library routines with simpler and safer interfaces, at very low cost.
    263 Hence, \CFA begins by leveraging the large repository of C libraries with little cost.
     272Hence, \CFA begins by leveraging the large repository of C libraries at little cost.
    264273
    265274\begin{comment}
     
    304313\end{comment}
    305314
    306 However, it is necessary to differentiate between C and \CFA code because of name overloading, as for \CC.
     315However, it is necessary to differentiate between C and \CFA code because of name \Index{overload}ing, as for \CC.
    307316For example, the C math-library provides the following routines for computing the absolute value of the basic types: ©abs©, ©labs©, ©llabs©, ©fabs©, ©fabsf©, ©fabsl©, ©cabsf©, ©cabs©, and ©cabsl©.
    308 Whereas, \CFA wraps each of these routines into ones with the common name ©abs©:
     317Whereas, \CFA wraps each of these routines into ones with the overloaded name ©abs©:
    309318\begin{cfa}
    310319char abs( char );
     
    326335Hence, there is the same need as in \CC, to know if a name is a C or \CFA name, so it can be correctly formed.
    327336There is no way around this problem, other than C's approach of creating unique names for each pairing of operation and type.
    328 This example strongly illustrates a core idea in \CFA: \emph{the power of a name}.
     337This example strongly illustrates a core idea in \CFA: \emph{the \Index{power of a name}}.
    329338The name ``©abs©'' evokes the notion of absolute value, and many mathematical types provide the notion of absolute value.
    330 Hence, knowing the name ©abs© should be sufficient to apply it to any type where it is applicable.
    331 The time savings and safety of using one name uniformly versus $N$ unique names should not be underestimated.
    332 
    333 
    334 \section[Compiling CFA Program]{Compiling \CFA Program}
     339Hence, knowing the name ©abs© is sufficient to apply it to any type where it is applicable.
     340The time savings and safety of using one name uniformly versus $N$ unique names cannot be underestimated.
     341
     342
     343\section[Compiling a CFA Program]{Compiling a \CFA Program}
    335344
    336345The command ©cfa© is used to compile \CFA program(s), and is based on the GNU \Indexc{gcc} command, \eg:
    337346\begin{cfa}
    338 cfa§\indexc{cfa}\index{compilation!cfa@©cfa©}§ [ gcc-options ] C/§\CFA§-files [ assembler/loader-files ]
     347cfa§\indexc{cfa}\index{compilation!cfa@©cfa©}§ [ gcc-options ] C/§\CFA{}§-files [ assembler/loader-files ]
    339348\end{cfa}
    340349\CFA programs having the following ©gcc© flags turned on:
     
    359368\Indexc{-debug}\index{compilation option!-debug@©-debug©}
    360369The program is linked with the debugging version of the runtime system.
    361 The debug version performs runtime checks to help during the debugging phase of a \CFA program, but substantially slows the execution of the program.
     370The debug version performs runtime checks to help during the debugging phase of a \CFA program, but can substantially slow program execution.
    362371The runtime checks should only be removed after the program is completely debugged.
    363372\textbf{This option is the default.}
     
    415424\end{description}
    416425These preprocessor variables allow conditional compilation of programs that must work differently in these situations.
    417 For example, to toggle between C and \CFA extensions, using the following:
     426For example, to toggle between C and \CFA extensions, use the following:
    418427\begin{cfa}
    419428#ifndef __CFORALL__
     
    426435
    427436
    428 \section{Constants Underscores}
    429 
    430 Numeric constants are extended to allow \Index{underscore}s within constants\index{constant!underscore}, \eg:
     437\section{Constant Underscores}
     438
     439Numeric constants are extended to allow \Index{underscore}s\index{constant!underscore}, \eg:
    431440\begin{cfa}
    4324412®_®147®_®483®_®648;                                    §\C{// decimal constant}§
     
    441450L®_®§"\texttt{\textbackslash{x}}§®_®§\texttt{ff}§®_®§\texttt{ee}"§;     §\C{// wide character constant}§
    442451\end{cfa}
    443 The rules for placement of underscores is as follows:
    444 \begin{enumerate}
     452The rules for placement of underscores are:
     453\begin{enumerate}[topsep=5pt,itemsep=5pt,parsep=0pt]
    445454\item
    446455A sequence of underscores is disallowed, \eg ©12__34© is invalid.
     
    463472\label{s:BackquoteIdentifiers}
    464473
    465 \CFA accommodates keyword clashes with existing C variable-names by syntactic transformations using the \CFA backquote escape-mechanism:
     474\CFA introduces in new keywords (see \VRef{s:CFAKeywords}) that can clash with existing C variable-names in legacy code.
     475Keyword clashes are accommodated by syntactic transformations using the \CFA backquote escape-mechanism:
    466476\begin{cfa}
    467477int ®`®otype®`® = 3;                    §\C{// make keyword an identifier}§
     
    491501
    492502
    493 \section{Labelled Continue/Break}
     503\section{\texorpdfstring{Labelled \LstKeywordStyle{continue} / \LstKeywordStyle{break}}{Labelled continue / break}}
    494504
    495505While C provides ©continue© and ©break© statements for altering control flow, both are restricted to one level of nesting for a particular control structure.
    496506Unfortunately, this restriction forces programmers to use \Indexc{goto} to achieve the equivalent control-flow for more than one level of nesting.
    497 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,Java}.
     507To 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}.
    498508For both ©continue© and ©break©, the target label must be directly associated with a ©for©, ©while© or ©do© statement;
    499509for ©break©, the target label can also be associated with a ©switch©, ©if© or compound (©{}©) statement.
    500510\VRef[Figure]{f:MultiLevelResumeTermination} shows the labelled ©continue© and ©break©, specifying which control structure is the target for exit, and the corresponding C program using only ©goto©.
    501511The innermost loop has 7 exit points, which cause resumption or termination of one or more of the 7 \Index{nested control-structure}s.
     512Java supports both labelled ©continue© and ©break© statements.
    502513
    503514\begin{figure}
     
    622633
    623634
    624 \section{Switch Statement}
     635\section{\texorpdfstring{\LstKeywordStyle{switch} Statement}{switch Statement}}
    625636
    626637C allows a number of questionable forms for the ©switch© statement:
     
    663674        ®// open input file
    664675®} else if ( argc == 2 ) {
    665         ®// open input file
     676        ®// open input file (duplicate)
    666677
    667678®} else {
     
    676687\begin{cfa}
    677688switch ( i ) {
    678   case 1: case 3: case 5:       // odd values
    679         // same action
     689  ®case 1: case 3: case 5:®     // odd values
     690        // odd action
    680691        break;
    681   case 2: case 4: case 6:       // even values
    682         // same action
     692  ®case 2: case 4: case 6:®     // even values
     693        // even action
    683694        break;
    684695}
     
    686697However, this situation is handled in other languages without fall-through by allowing a list of case values.
    687698While 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 virtually all other programming languages with a ©switch© statement.
    688 Hence, default fall-through semantics results in a large number of programming errors as programmers often forget the ©break© statement at the end of a ©case© clause, resulting in inadvertent fall-through.
     699Hence, 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.
    689700
    690701\item
     
    770781and 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.
    771782\end{itemize}
    772 These observations help to put the \CFA changes to the ©switch© into perspective.
     783These observations put into perspective the \CFA changes to the ©switch©.
    773784\begin{enumerate}
    774785\item
     
    791802  case 7:
    792803        ...
    793         ®break®                                         §\C{// explicit end of switch}§
     804        ®break®                                         §\C{// redundant explicit end of switch}§
    794805  default:
    795806        j = 3;
     
    797808\end{cfa}
    798809Like the ©switch© statement, the ©choose© statement retains the fall-through semantics for a list of ©case© clauses;
    799 the implicit ©break© is applied only at the end of the \emph{statements} following a ©case© clause.
    800 The explicit ©fallthru© is retained because it is a C-idiom most C programmers expect, and its absence might discourage programmers from using the ©choose© statement.
     810An implicit ©break© is applied only at the end of the \emph{statements} following a ©case© clause.
     811An explicit ©fallthru© is retained because it is a C-idiom most C programmers expect, and its absence might discourage programmers from using the ©choose© statement.
    801812As well, allowing an explicit ©break© from the ©choose© is a carry over from the ©switch© statement, and expected by C programmers.
    802813\item
     
    827838
    828839
    829 \section{Case Clause}
     840\section{\texorpdfstring{\LstKeywordStyle{case} Clause}{case Clause}}
    830841
    831842C restricts the ©case© clause of a ©switch© statement to a single value.
     
    900911\begin{cfa}
    901912case ®1~5, 12~21, 35~42®:
     913\end{cfa}
     914
     915
     916\section{\texorpdfstring{\LstKeywordStyle{with} Clause / Statement}{with Clause / Statement}}
     917\label{s:WithClauseStatement}
     918
     919In \Index{object-oriented} programming, there is an implicit first parameter, often names \textbf{©self©} or \textbf{©this©}, which is elided.
     920\begin{C++}
     921class C {
     922        int i, j;
     923        int mem() {              ®// implicit "this" parameter
     924                i = 1;          ®// this->i
     925®               j = 3;          ®// this->j
     926®       }
     927}
     928\end{C++}
     929Since CFA is non-object-oriented, the equivalent object-oriented program looks like:
     930\begin{cfa}
     931struct C {
     932        int i, j;
     933};
     934int mem( C &this ) {    // explicit "this" parameter
     935        ®this.®i = 1;                     // "this" is not elided
     936        ®this.®j = 2;
     937}
     938\end{cfa}
     939but it is cumbersome having to write "©this.©" many times in a member.
     940\CFA provides a ©with© clause/statement to elided the "©this.©".
     941\begin{cfa}
     942int mem( C &this ) ®with this® {
     943        i = 1;                  ®// this.i
     944®       j = 2;                  ®// this.j
     945®}
     946\end{cfa}
     947which extends to multiple routine parameters:
     948\begin{cfa}
     949struct D {
     950        double m, n;
     951};
     952int mem2( C &this1, D &this2 ) ®with this1, this2® {
     953        i = 1; j = 2;
     954        m = 1.0; n = 2.0;
     955}
     956\end{cfa}
     957The ©with© clause/statement comes from Pascal~\cite[\S~4.F]{Pascal}.
     958
     959The statement form is used within a block:
     960\begin{cfa}
     961int foo() {
     962        struct S1 { ... } s1;
     963        struct S2 { ... } s2;
     964        ®with s1® {
     965                // access fields of s1 without qualification
     966                ®with s2® {  // nesting
     967                        // access fields of s2 without qualification
     968                }
     969        }
     970        ®with s1, s2® {
     971                // access unambiguous fields of s1 and s2 without qualification
     972        }
     973}
     974\end{cfa}
     975
     976Names clashes when opening multiple structures are ambiguous.
     977\begin{cfa}
     978struct A { int i; int j; } a, c;
     979struct B { int i; int k; } b, c;
     980®with a, b® {
     981        j + k;                                          §\C{// unambiguous}§
     982        i;                                                      §\C{// ambiguous}§
     983        a.i + b.i;                                      §\C{// unambiguous}§
     984}
     985®with c® {                                              §\C{// ambiguous}§
     986        // ...
     987}
    902988\end{cfa}
    903989
     
    11361222
    11371223
    1138 \section{Pointer/Reference}
     1224\section{Pointer / Reference}
    11391225
    11401226C provides a \newterm{pointer type};
     
    52585344
    52595345
    5260 \section{\CFA Keywords}
     5346\section{\texorpdfstring{\CFA Keywords}{Cforall Keywords}}
    52615347\label{s:CFAKeywords}
    52625348
     5349\CFA introduces the following new keywords.
     5350
    52635351\begin{quote2}
    5264 \begin{tabular}{llll}
     5352\begin{tabular}{lllll}
    52655353\begin{tabular}{@{}l@{}}
    5266 ©_AT©                   \\
     5354©_At©                   \\
    52675355©catch©                 \\
    52685356©catchResume©   \\
    52695357©choose©                \\
    52705358©coroutine©             \\
    5271 ©disable©               \\
    52725359\end{tabular}
    52735360&
    52745361\begin{tabular}{@{}l@{}}
     5362©disable©               \\
    52755363©dtype©                 \\
    52765364©enable©                \\
    52775365©fallthrough©   \\
    52785366©fallthru©              \\
    5279 ©finally©               \\
    5280 ©forall©                \\
    52815367\end{tabular}
    52825368&
    52835369\begin{tabular}{@{}l@{}}
     5370©finally©               \\
     5371©forall©                \\
    52845372©ftype©                 \\
    52855373©lvalue©                \\
    52865374©monitor©               \\
     5375\end{tabular}
     5376&
     5377\begin{tabular}{@{}l@{}}
    52875378©mutex©                 \\
    52885379©one_t©                 \\
    52895380©otype©                 \\
     5381©throw©                 \\
     5382©throwResume©   \\
    52905383\end{tabular}
    52915384&
    52925385\begin{tabular}{@{}l@{}}
    5293 ©throw©                 \\
    5294 ©throwResume©   \\
    52955386©trait©                 \\
    52965387©try©                   \\
    52975388©ttype©                 \\
    52985389©zero_t©                \\
     5390                                \\
    52995391\end{tabular}
    53005392\end{tabular}
  • src/Parser/lex.ll

    ra0b3e32 r35b06a8  
    1010 * Created On       : Sat Sep 22 08:58:10 2001
    1111 * Last Modified By : Peter A. Buhr
    12  * Last Modified On : Tue Jul 11 21:30:51 2017
    13  * Update Count     : 534
     12 * Last Modified On : Wed Jul 12 18:04:44 2017
     13 * Update Count     : 535
    1414 */
    1515
     
    274274__volatile__    { KEYWORD_RETURN(VOLATILE); }                   // GCC
    275275while                   { KEYWORD_RETURN(WHILE); }
     276with                    { KEYWORD_RETURN(WITH); }                               // CFA
    276277zero_t                  { NUMERIC_RETURN(ZERO_T); }                             // CFA
    277278
  • src/Parser/parser.yy

    ra0b3e32 r35b06a8  
    99// Author           : Peter A. Buhr
    1010// Created On       : Sat Sep  1 20:22:55 2001
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Tus Jul 11 13:39:00 2017
    13 // Update Count     : 2416
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Wed Jul 12 18:23:36 2017
     13// Update Count     : 2426
    1414//
    1515
     
    129129%token ATTRIBUTE EXTENSION                                                              // GCC
    130130%token IF ELSE SWITCH CASE DEFAULT DO WHILE FOR BREAK CONTINUE GOTO RETURN
    131 %token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT        // CFA
     131%token CHOOSE DISABLE ENABLE FALLTHRU TRY CATCH CATCHRESUME FINALLY THROW THROWRESUME AT WITH   // CFA
    132132%token ASM                                                                                              // C99, extension ISO/IEC 9899:1999 Section J.5.10(1)
    133133%token ALIGNAS ALIGNOF GENERIC STATICASSERT                             // C11
     
    184184// statements
    185185%type<sn> labeled_statement                             compound_statement                      expression_statement            selection_statement
    186 %type<sn> iteration_statement                   jump_statement                          exception_statement                     asm_statement
     186%type<sn> iteration_statement                   jump_statement
     187%type<sn> with_statement                                exception_statement                     asm_statement
    187188%type<sn> fall_through_opt                              fall_through
    188189%type<sn> statement                                             statement_list
    189190%type<sn> block_item_list                               block_item
    190 %type<sn> case_clause
     191%type<sn> with_clause_opt
    191192%type<en> case_value
    192 %type<sn> case_value_list                               case_label                                      case_label_list
     193%type<sn> case_clause                                   case_value_list                         case_label                                      case_label_list
    193194%type<sn> switch_clause_list_opt                switch_clause_list                      choose_clause_list_opt          choose_clause_list
    194195%type<sn> /* handler_list */                    handler_clause                          finally_clause
     
    729730        | iteration_statement
    730731        | jump_statement
     732        | with_statement
    731733        | exception_statement
    732734        | asm_statement
     
    934936        | THROWRESUME assignment_expression_opt AT assignment_expression ';' // handles reresume
    935937                { $$ = new StatementNode( build_resume_at( $2, $4 ) ); }
     938        ;
     939
     940with_statement:
     941        WITH identifier_list compound_statement
     942                { $$ = (StatementNode *)0; }                                    // FIX ME
    936943        ;
    937944
     
    22122219        ;
    22132220
     2221with_clause_opt:
     2222        // empty
     2223                { $$ = (StatementNode *)0; }                                    // FIX ME
     2224        | WITH identifier_list
     2225                { $$ = (StatementNode *)0; }                                    // FIX ME
     2226        ;
     2227
    22142228function_definition:
    2215         cfa_function_declaration compound_statement                     // CFA
     2229        cfa_function_declaration with_clause_opt compound_statement     // CFA
    22162230                {
    22172231                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22182232                        typedefTable.leaveScope();
    2219                         $$ = $1->addFunctionBody( $2 );
    2220                 }
    2221         | declaration_specifier function_declarator compound_statement
     2233                        $$ = $1->addFunctionBody( $3 );
     2234                }
     2235        | declaration_specifier function_declarator with_clause_opt compound_statement
    22222236                {
    22232237                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22242238                        typedefTable.leaveScope();
    2225                         $$ = $2->addFunctionBody( $3 )->addType( $1 );
    2226                 }
    2227         | type_qualifier_list function_declarator compound_statement
     2239                        $$ = $2->addFunctionBody( $4 )->addType( $1 );
     2240                }
     2241        | type_qualifier_list function_declarator with_clause_opt compound_statement
    22282242                {
    22292243                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22302244                        typedefTable.leaveScope();
    2231                         $$ = $2->addFunctionBody( $3 )->addQualifiers( $1 );
    2232                 }
    2233         | declaration_qualifier_list function_declarator compound_statement
     2245                        $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );
     2246                }
     2247        | declaration_qualifier_list function_declarator with_clause_opt compound_statement
    22342248                {
    22352249                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22362250                        typedefTable.leaveScope();
    2237                         $$ = $2->addFunctionBody( $3 )->addQualifiers( $1 );
    2238                 }
    2239         | declaration_qualifier_list type_qualifier_list function_declarator compound_statement
     2251                        $$ = $2->addFunctionBody( $4 )->addQualifiers( $1 );
     2252                }
     2253        | declaration_qualifier_list type_qualifier_list function_declarator with_clause_opt compound_statement
    22402254                {
    22412255                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22422256                        typedefTable.leaveScope();
    2243                         $$ = $3->addFunctionBody( $4 )->addQualifiers( $2 )->addQualifiers( $1 );
     2257                        $$ = $3->addFunctionBody( $5 )->addQualifiers( $2 )->addQualifiers( $1 );
    22442258                }
    22452259
    22462260                // Old-style K&R function definition, OBSOLESCENT (see 4)
    2247         | declaration_specifier KR_function_declarator push KR_declaration_list_opt compound_statement
     2261        | declaration_specifier KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22482262                {
    22492263                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22502264                        typedefTable.leaveScope();
    2251                         $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addType( $1 );
    2252                 }
    2253         | type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
     2265                        $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addType( $1 );
     2266                }
     2267        | type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22542268                {
    22552269                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22562270                        typedefTable.leaveScope();
    2257                         $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addQualifiers( $1 );
     2271                        $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 );
    22582272                }
    22592273
    22602274                // Old-style K&R function definition with "implicit int" type_specifier, OBSOLESCENT (see 4)
    2261         | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
     2275        | declaration_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22622276                {
    22632277                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22642278                        typedefTable.leaveScope();
    2265                         $$ = $2->addOldDeclList( $4 )->addFunctionBody( $5 )->addQualifiers( $1 );
    2266                 }
    2267         | declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt compound_statement
     2279                        $$ = $2->addOldDeclList( $4 )->addFunctionBody( $6 )->addQualifiers( $1 );
     2280                }
     2281        | declaration_qualifier_list type_qualifier_list KR_function_declarator push KR_declaration_list_opt with_clause_opt compound_statement
    22682282                {
    22692283                        typedefTable.addToEnclosingScope( TypedefTable::ID );
    22702284                        typedefTable.leaveScope();
    2271                         $$ = $3->addOldDeclList( $5 )->addFunctionBody( $6 )->addQualifiers( $2 )->addQualifiers( $1 );
     2285                        $$ = $3->addOldDeclList( $5 )->addFunctionBody( $7 )->addQualifiers( $2 )->addQualifiers( $1 );
    22722286                }
    22732287        ;
Note: See TracChangeset for help on using the changeset viewer.