Changeset 5fec3f6


Ignore:
Timestamp:
May 8, 2018, 11:55:44 AM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, with_gc
Children:
4990812
Parents:
14a61b5 (diff), 387c9a1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
1 added
1 deleted
9 edited
1 moved

Legend:

Unmodified
Added
Removed
  • doc/bibliography/pl.bib

    r14a61b5 r5fec3f6  
    4040% @string{mathann="Math. Ann."}
    4141
     42@misc{CFAStackEvaluation,
     43    author      = {Aaron Moss},
     44    title       = {\textsf{C}$\mathbf{\forall}$ Stack Evaluation Programs},
     45    year        = 2018,
     46    howpublished= {\href{https://plg.uwaterloo.ca/~cforall/evaluation.zip}{https://plg.uwaterloo.ca/\-\-$\sim$cforall/\-StackEvaluation.zip}},
     47    optnote     = {[Accessed May 2018]},
     48}
     49
    4250% A
    4351
     
    782790    howpublished= {\href{http://www.boost.org/doc/libs/1_61_0/libs/coroutine/doc/html/index.html}
    783791                  {{http://www.boost.org/\-doc/\-libs/1\_61\_0/\-libs/\-coroutine/\-doc/\-html/\-index.html}}},
    784     note        = {Accessed: 2016-09},
     792    optnote     = {Accessed: 2016-09},
    785793}
    786794
     
    855863    keywords    = {ANSI C 89},
    856864    contributer = {gjditchfield@plg},
    857     title       = {American National Standard for Information Systems -- Programming Language -- {C}},
     865    author      = {C90},
     866    title       = {Programming Languages -- {C}},
    858867    organization= {American National Standards Institute},
    859     address     = {1430 Broadway, New York, New York  10018},
    860     month       = dec,
    861     year        = 1989,
    862     note        = {X3.159-1989}
     868    address     = {New York, NY, U.S.A.},
     869    year        = 1990,
     870    note        = {ANSI/ISO 9899-1990}
    863871}
    864872
     
    888896    title       = {\textsf{C}{$\mathbf{\forall}$} Features},
    889897    howpublished= {\url{https://plg.uwaterloo.ca/~cforall/features}},
    890     note        = {Accessed: 2018-01-01},
     898    optnote     = {Accessed: 2018-01-01},
    891899}
    892900
     
    16401648}
    16411649
     1650@misc{Taylor10,
     1651    keywords    = {const, poisoning},
     1652    contributer = {pabuhr@plg},
     1653    author      = {Ian Lance Taylor},
     1654    title       = {const},
     1655    month       = oct,
     1656    year        = 2010,
     1657    howpublished= {\href{https://www.airs.com/blog/archives/428}
     1658                  {https://www.airs.com/\-blog/\-archives/\-428}},
     1659    optnote     = {Accessed: 2018-05},
     1660}
     1661
    16421662@phdthesis{Ditchfield92,
    16431663    keywords    = {C, parametric polymorphism, overloading},
     
    27552775@misc{GCCExtensions,
    27562776    contributer = {a3moss@uwaterloo.ca},
    2757     key         = {{GNU}},
     2777    key         = {C Extensions},
    27582778    author      = {{C Extensions}},
    27592779    title       = {Extensions to the {C} Language Family},
    27602780    year        = 2014,
    27612781    howpublished= {\href{https://gcc.gnu.org/onlinedocs/gcc-4.7.2/gcc/C-Extensions.html}{https://\-gcc.gnu.org/\-onlinedocs/\-gcc-4.7.2/\-gcc/\-C\-Extensions.html}},
    2762     note        = {Accessed: 2017-04-02},
     2782    optnote     = {Accessed: 2017-04-02},
    27632783}
    27642784
     
    31373157    year        = 2014,
    31383158    howpublished= {https://developer.gnome.org/gobject/stable/},
    3139     note        = {Accessed: 2017-04},
     3159    optnote     = {Accessed: 2017-04},
    31403160}
    31413161
     
    32093229
    32103230% H
     3231
     3232@manual{Haskell10,
     3233    keywords    = {Haskell},
     3234    contributer = {pabuhr@plg},
     3235    author      = {Haskell},
     3236    title       = {Haskell 2010 Language Report},
     3237    edition     = {{S}imon {M}arlow},
     3238    year        = 2010,
     3239    note        = {\href{https://haskell.org/definition/haskell2010.pdf}{https://haskell.org/\-definition/\-haskell2010.pdf}},
     3240}
    32113241
    32123242@article{Michael04a,
     
    37603790    keywords    = {concurrency, critical section},
    37613791    contributer = {pabuhr@plg},
    3762     author      = {Dominic Duggan and Gordon V. Cormack and John Ophel},
     3792    author      = {Dominic Duggan and G. V. Cormack and John Ophel},
    37633793    title       = {Kinded Type Inference for Parametric Overloading},
    37643794    journal     = acta,
     
    46854715    year        = 2015,
    46864716    howpublished= {\href{https://developer.apple.com/library/content/documentation/General/Conceptual/DevPedia-CocoaCore/ObjectiveC.html}{https://developer.apple.com/\-library/\-content/\-documentation/\-General/\-Conceptual/\-DevPedia-\-CocoaCore/\-ObjectiveC.html}},
    4687     note        = {Accessed: 2018-03}
     4717    optnote     = {Accessed: 2018-03}
    46884718}
    46894719
     
    46954725    year        = 2015,
    46964726    howpublished= {\href{https://developer.apple.com/library/content/documentation/Xcode/Conceptual/RN-Xcode-Archive/Chapters/xc7_release_notes.html}{https://developer.apple.com/\-library/\-content/\-documentation/\-Xcode/\-Conceptual/\-RN-Xcode-Archive/\-Chapters/\-xc7\_release\_notes.html}},
    4697     note        = {Accessed: 2017-04}
     4727    optnote     = {Accessed: 2017-04}
    46984728}
    46994729
     
    57575787    keywords    = {Cyclone, existential types, polymorphism, type variables},
    57585788    contributer = {a3moss@plg},
    5759     author      = {Dan Grossman},
     5789    author      = {D. Grossman},
    57605790    title       = {Quantified Types in an Imperative Language},
    57615791    journal     = toplas,
     
    67626792    title       = {{TIOBE} Index},
    67636793    howpublished= {\href{http://www.tiobe.com/tiobe_index}{http://\-www.tiobe.com/\-tiobe\_index}},
    6764     note        = {Accessed: 2018-09},
     6794    optnote     = {Accessed: 2018-09},
    67656795}
    67666796
     
    70877117    year        = 2017,
    70887118    howpublished= {\url{https://wiki.gnome.org/Projects/Vala/Manual}},
    7089     note        = {Accessed: 2017-04}
     7119    optnote     = {Accessed: 2017-04}
    70907120}
    70917121
  • doc/papers/AMA/AMA-stix/Documents/README.txt

    r14a61b5 r5fec3f6  
    1313%   NJDnatbib.sty --> NJD natbib reference package.
    1414%   Stix-Fonts (folder) -->   Stix font files
    15 
    16 %   MiKTeX 2.9 (Freeware software) is required to install STIX/LATO fonts
    17 %   Download MiKTeX installer & instructions from the below URLs
    18         https://miktex.org/download
    19         Instructions to install the basic MiKTeX installer
    20         https://miktex.org/howto/install-miktex
    21 
    22 %   Execute(double click) --> Windows-Stix-fontinstaller.exe from Stix-Fonts folder (This EXE file will install fonts to local drive) (please rename Windows-Stix-fontinstaller.e_xe to Windows-Stix-fontinstaller.exe)
     15%   Execute(double click) --> Windows-Stix-fontinstaller.exe from Stix-Fonts folder (This EXE file will install fonts to local drive)
    2316%   Still shows font error, please do the following
    2417%   Start-->run--> type "mo_edmin.exe" and press enter
  • doc/papers/AMA/AMA-stix/ama/WileyNJD-AMA.bst

    r14a61b5 r5fec3f6  
    502502      editor empty$
    503503      { booktitle emphasize * }
    504       { " " * format.editors * " " * booktitle emphasize * ", " * }
     504    { " " * format.editors * " " * booktitle emphasize * ", " * }
    505505      if$
    506506    }
     
    691691    { format.journal emphasize "journal" output.check
    692692      format.date add.semicolon "year" output.check
     693      blank.sep
    693694      format.volume output
    694695      format.number output
     
    824825      new.block
    825826      format.pages output
     827      new.block
    826828      organization output
     829      new.block
    827830      publisher output
    828831      inproformat.date "year" output.check
     
    863866    { new.block organization new.block address new.block.checkb
    864867      organization output
     868      new.block
    865869      address output
    866870    }
     
    883887  new.block
    884888  school "school" output.check
     889  new.block
    885890  address output
    886891  format.date "year" output.check
     
    927932  "PhD thesis" format.thesis.type output.nonnull
    928933  school "school" output.check
     934  new.block
    929935  address output
    930936  format.date "year" output.check
  • doc/papers/AMA/AMA-stix/ama/WileyNJD-v2.cls

    r14a61b5 r5fec3f6  
    484484\if@STIXLargeOneCol%
    485485\RequirePackage[not1,notextcomp,lcgreekalpha]{stix}%
    486 %\usepackage[scaled]{helvet}
    487 %\renewcommand\familydefault{\sfdefault}
    488486\usepackage[T1]{fontenc}
    489487\BXhsize=170mm%
     
    528526%\RequirePackage[not1,notextcomp,lcgreekalpha]{stix}%
    529527
    530 \captionsetup[figure]{labelformat=simple, labelsep=space, skip=10pt, labelfont=bf}
    531 \captionsetup[table]{labelformat=simple, labelsep=space, skip=10pt, labelfont=bf}
    532 \renewcommand{\thefigure}{\arabic{figure}}
    533 
    534 \renewcommand{\thetable}{\arabic{table}}
     528\captionsetup[figure]{labelformat=simple, labelsep=none, skip=10pt, labelfont=bf}
     529\captionsetup[table]{labelformat=simple, labelsep=none, skip=10pt, labelfont=bf}
     530\renewcommand{\thefigure}{\arabic{figure}\enspace }
     531
     532\renewcommand{\thetable}{\arabic{table}\enspace }
    535533
    536534\renewcommand\figurename{\textbf{FIGURE}}%%
     
    14141412\gdef\@stix@font@defn{%
    14151413  %
    1416 %  \def\infoboxfont{\fontfamily{tim}\fontsize{8}{8}\selectfont}%
     1414  \def\infoboxfont{\fontfamily{tim}\fontsize{8}{8}\selectfont}%
    14171415  %
    1418 %  \def\watermarkfont{\reset@font\fontfamily{\ffdefault}\fontsize{45}{45}\bfseries\selectfont}
     1416  \def\watermarkfont{\reset@font\fontfamily{\ffdefault}\fontsize{45}{45}\bfseries\selectfont}
    14191417  %
    14201418  \def\pagenumfont{\rmfamily\fontsize{7}{9}\bfseries\selectfont}%
     
    14291427  \def\arttypefont{\rmfamily\fontsize{9}{9}\fontseries{b}\selectfont}%
    14301428  \def\SParttypefont{\rmfamily\fontsize{9}{12}\fontseries{b}\selectfont}%
    1431   \def\titlefont{\rmfamily\fontsize{18}{23}\bfseries\selectfont\leftskip\z@\rightskip\z@ plus1fil}%
     1429  \def\titlefont{\rmfamily\fontsize{18}{23}\bfseries\selectfont\leftskip\z@\rightskip\z@ plus1fil\let\mathbcal\titmathbcal}%
    14321430  \def\subtitlefont{\rmfamily\fontsize{16}{21}\bfseries\selectfont\leftskip\z@\rightskip\z@ plus1fil}%
    14331431  \def\Authorfont{\rmfamily\fontsize{12}{18}\selectfont\leftskip\z@\rightskip\z@ plus1fil}%
     
    14841482\gdef\@lato@font@defn{%
    14851483  %
    1486 %  \def\infoboxfont{\fontfamily{tim}\fontsize{8}{8}\selectfont}%
     1484  \def\infoboxfont{\fontfamily{tim}\fontsize{8}{8}\selectfont}%
    14871485  %
    1488 %  \def\watermarkfont{\reset@font\fontfamily{\ffdefault}\fontsize{45}{45}\bfseries\selectfont}
     1486  \def\watermarkfont{\reset@font\fontfamily{\ffdefault}\fontsize{45}{45}\bfseries\selectfont}
    14891487  %
    14901488  \def\pagenumfont{\rmfamily\fontsize{7}{9}\bfseries\selectfont}%
     
    32493247    \fi
    32503248  \fi%
    3251   \renewcommand\thefigure{\@Alph\c@section\arabic{figure}}%
    3252   \renewcommand\thetable{\@Alph\c@section\arabic{table}}%
     3249  \renewcommand\thefigure{\@Alph\c@section\arabic{figure}\enspace }%
     3250  \renewcommand\thetable{\@Alph\c@section\arabic{table}\enspace }%
    32533251  \renewcommand\theequation{\@Alph\c@section\arabic{equation}}%
    32543252}{%
  • doc/papers/general/.gitignore

    r14a61b5 r5fec3f6  
    88Paper.out.ps
    99WileyNJD-AMA.bst
     10evaluation.zip
  • doc/papers/general/Makefile

    r14a61b5 r5fec3f6  
    4545        @rm -frv ${DOCUMENT} ${BASE}.ps WileyNJD-AMA.bst ${BASE}.out.ps ${Build}
    4646
     47evaluation.zip :
     48        zip -x evaluation/.gitignore  -x evaluation/timing.xlsx -x evaluation/timing.dat -r evaluation.zip evaluation
     49
    4750# File Dependencies #
    4851
     
    6669## Define the default recipes.
    6770
    68 ${Build}:
     71${Build} :
    6972        mkdir -p ${Build}
    7073
    71 ${BASE}.out.ps: ${Build}
     74${BASE}.out.ps : ${Build}
    7275        ln -fs ${Build}/Paper.out.ps .
    7376
    74 WileyNJD-AMA.bst:
     77WileyNJD-AMA.bst :
    7578        ln -fs ../AMA/AMA-stix/ama/WileyNJD-AMA.bst .
    7679
  • doc/papers/general/Paper.tex

    r14a61b5 r5fec3f6  
    5959%\DeclareTextCommandDefault{\textunderscore}{\leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.1ex}}}
    6060\renewcommand{\textunderscore}{\leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.075ex}}}
     61
     62\renewcommand*{\thefootnote}{\alph{footnote}} % hack because fnsymbol does not work
     63%\renewcommand*{\thefootnote}{\fnsymbol{footnote}}
    6164
    6265\makeatletter
     
    174177\lstMakeShortInline@%
    175178
     179\let\OLDthebibliography\thebibliography
     180\renewcommand\thebibliography[1]{
     181  \OLDthebibliography{#1}
     182  \setlength{\parskip}{0pt}
     183  \setlength{\itemsep}{4pt plus 0.3ex}
     184}
    176185
    177186\title{\texorpdfstring{\protect\CFA : Adding Modern Programming Language Features to C}{Cforall : Adding Modern Programming Language Features to C}}
     
    191200The C programming language is a foundational technology for modern computing with millions of lines of code implementing everything from commercial operating-systems to hobby projects.
    192201This installation base and the programmers producing it represent a massive software-engineering investment spanning decades and likely to continue for decades more.
    193 Nevertheless, C, first standardized over thirty years ago, lacks many features that make programming in more modern languages safer and more productive.
    194 The goal of the \CFA project is to create an extension of C that provides modern safety and productivity features while still ensuring strong backwards compatibility with C and its programmers.
     202Nevertheless, C, first standardized almost forty years ago, lacks many features that make programming in more modern languages safer and more productive.
     203
     204The goal of the \CFA project (pronounced ``C-for-all'') is to create an extension of C that provides modern safety and productivity features while still ensuring strong backwards compatibility with C and its programmers.
    195205Prior projects have attempted similar goals but failed to honour C programming-style; for instance, adding object-oriented or functional programming with garbage collection is a non-starter for many C developers.
    196206Specifically, \CFA is designed to have an orthogonal feature-set based closely on the C programming paradigm, so that \CFA features can be added \emph{incrementally} to existing C code-bases, and C programmers can learn \CFA extensions on an as-needed basis, preserving investment in existing code and programmers.
     
    226236Love it or hate it, C is extremely popular, highly used, and one of the few systems languages.
    227237In many cases, \CC is often used solely as a better C.
    228 Nevertheless, C, first standardized over thirty years ago, lacks many features that make programming in more modern languages safer and more productive.
     238Nevertheless, C, first standardized almost forty years ago~\cite{ANSI89:C}, lacks many features that make programming in more modern languages safer and more productive.
    229239
    230240\CFA (pronounced ``C-for-all'', and written \CFA or Cforall) is an evolutionary extension of the C programming language that adds modern language-features to C, while maintaining both source and runtime compatibility with C and a familiar programming model for programmers.
     
    292302The \CFA tests are 290+ files and 27,000+ lines of code.
    293303The tests illustrate syntactic and semantic features in \CFA, plus a growing number of runtime benchmarks.
    294 The tests check for correctness and are used for daily regression testing of commits (3800+).
     304The tests check for correctness and are used for daily regression testing of 3800+ commits.
    295305
    296306Finally, it is impossible to describe a programming language without usages before definitions.
     
    324334int max( int a, int b ) { return a < b ? b : a; }  $\C{// (3)}$
    325335double max( double a, double b ) { return a < b ? b : a; }  $\C{// (4)}\CRT$
    326 max( 7, -max );                                         $\C[2.75in]{// uses (3) and (1), by matching int from constant 7}$
     336max( 7, -max );                                         $\C{// uses (3) and (1), by matching int from constant 7}$
    327337max( max, 3.14 );                                       $\C{// uses (4) and (2), by matching double from constant 3.14}$
    328 max( max, -max );                                       $\C{// ERROR: ambiguous}$
    329 int m = max( max, -max );                       $\C{// uses (3) and (1) twice, by matching return type}\CRT$
     338max( max, -max );                                       $\C{// ERROR, ambiguous}$
     339int m = max( max, -max );                       $\C{// uses (3) and (1) twice, by matching return type}$
    330340\end{cfa}
    331341
     
    336346As is shown later, there are a number of situations where \CFA takes advantage of available type information to disambiguate, where other programming languages generate ambiguities.
    337347
    338 \Celeven added @_Generic@ expressions, which is used in preprocessor macros to provide a form of ad-hoc polymorphism;
     348\Celeven added @_Generic@ expressions~\cite[\S~6.5.1.1]{C11}, which is used with preprocessor macros to provide ad-hoc polymorphism;
    339349however, this polymorphism is both functionally and ergonomically inferior to \CFA name overloading.
    340350The macro wrapping the generic expression imposes some limitations;
    341351\eg, it cannot implement the example above, because the variables @max@ are ambiguous with the functions @max@.
    342352Ergonomic limitations of @_Generic@ include the necessity to put a fixed list of supported types in a single place and manually dispatch to appropriate overloads, as well as possible namespace pollution from the dispatch functions, which must all have distinct names.
    343 For backwards compatibility, \CFA supports @_Generic@ expressions, but it is an unnecessary mechanism. \TODO{actually implement that}
     353\CFA supports @_Generic@ expressions for backwards compatibility, but it is an unnecessary mechanism. \TODO{actually implement that}
    344354
    345355% http://fanf.livejournal.com/144696.html
     
    369379\begin{cfa}
    370380forall( otype T `| { T ?+?(T, T); }` ) T twice( T x ) { return x `+` x; }  $\C{// ? denotes operands}$
    371 int val = twice( twice( 3.7 ) );
     381int val = twice( twice( 3.7 ) );  $\C{// val == 14}$
    372382\end{cfa}
    373383which works for any type @T@ with a matching addition operator.
    374384The polymorphism is achieved by creating a wrapper function for calling @+@ with @T@ bound to @double@, then passing this function to the first call of @twice@.
    375385There is now the option of using the same @twice@ and converting the result to @int@ on assignment, or creating another @twice@ with type parameter @T@ bound to @int@ because \CFA uses the return type~\cite{Cormack81,Baker82,Ada} in its type analysis.
    376 The first approach has a late conversion from @double@ to @int@ on the final assignment, while the second has an eager conversion to @int@.
     386The first approach has a late conversion from @double@ to @int@ on the final assignment, while the second has an early conversion to @int@.
    377387\CFA minimizes the number of conversions and their potential to lose information, so it selects the first approach, which corresponds with C-programmer intuition.
    378388
     
    420430\begin{cfa}
    421431forall( otype T | { int ?<?( T, T ); } ) void qsort( const T * arr, size_t size ) { /* use C qsort */ }
    422 {
     432int main() {
    423433        int ?<?( double x, double y ) { return x `>` y; } $\C{// locally override behaviour}$
    424         qsort( vals, size );                                    $\C{// descending sort}$
     434        qsort( vals, 10 );                                                      $\C{// descending sort}$
    425435}
    426436\end{cfa}
     
    534544\begin{cquote}
    535545\lstDeleteShortInline@%
    536 \begin{tabular}{@{}l|@{\hspace{2\parindentlnth}}l@{}}
    537 \begin{cfa}
    538 forall( otype R, otype S ) struct pair {
     546\begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}}
     547\begin{cfa}
     548`forall( otype R, otype S )` struct pair {
    539549        R first;        S second;
    540550};
     
    578588\begin{cfa}
    579589struct _pair_conc0 {
    580         const char * first;
    581         int second;
     590        const char * first;  int second;
    582591};
    583592\end{cfa}
     
    587596\begin{cfa}
    588597struct _pair_conc1 {
    589         void * first;
    590         void * second;
     598        void * first, * second;
    591599};
    592600\end{cfa}
     
    645653\begin{cquote}
    646654\lstDeleteShortInline@%
    647 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
     655\begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}}
    648656\begin{cfa}
    649657forall( dtype Unit ) struct scalar { unsigned long value; };
     
    661669                                                        half_marathon;
    662670scalar(litres) two_pools = pool + pool;
    663 `marathon + pool;`      // compilation ERROR
     671`marathon + pool;`      // ERROR, mismatched types
    664672\end{cfa}
    665673\end{tabular}
     
    10061014\begin{cfa}
    10071015forall( dtype T0, dtype T1 | sized(T0) | sized(T1) ) struct _tuple2 {
    1008         T0 field_0;                                                             $\C{// generated before the first 2-tuple}$
    1009         T1 field_1;
     1016        T0 field_0;  T1 field_1;                                        $\C{// generated before the first 2-tuple}$
    10101017};
    10111018_tuple2(int, int) f() {
    10121019        _tuple2(double, double) x;
    10131020        forall( dtype T0, dtype T1, dtype T2 | sized(T0) | sized(T1) | sized(T2) ) struct _tuple3 {
    1014                 T0 field_0;                                                     $\C{// generated before the first 3-tuple}$
    1015                 T1 field_1;
    1016                 T2 field_2;
     1021                T0 field_0;  T1 field_1;  T2 field_2;   $\C{// generated before the first 3-tuple}$
    10171022        };
    10181023        _tuple3(int, double, int) y;
    10191024}
    10201025\end{cfa}
    1021 {\sloppy
    1022 Tuple expressions are then simply converted directly into compound literals, \eg @[5, 'x', 1.24]@ becomes @(_tuple3(int, char, double)){ 5, 'x', 1.24 }@.
    1023 \par}%
     1026Tuple expressions are then converted directly into compound literals, \eg @[5, 'x', 1.24]@ becomes @(_tuple3(int, char,@ @double)){ 5, 'x', 1.24 }@.
    10241027
    10251028\begin{comment}
     
    11051108\begin{cquote}
    11061109\lstDeleteShortInline@%
    1107 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
     1110\begin{tabular}{@{}l|@{\hspace{2\parindentlnth}}l@{}}
    11081111\multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{\CFA}}    & \multicolumn{1}{c}{\textbf{C}}        \\
    11091112\begin{cfa}
     
    11741177\centering
    11751178\lstDeleteShortInline@%
    1176 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
    1177 \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{\CFA}}    & \multicolumn{1}{c}{\textbf{C}}        \\
     1179\begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}}
     1180\multicolumn{1}{c|@{\hspace{\parindentlnth}}}{\textbf{\CFA}}    & \multicolumn{1}{c}{\textbf{C}}        \\
    11781181\begin{cfa}
    11791182`choose` ( day ) {
    11801183  case Mon~Thu:  // program
    11811184
    1182   case Fri:  // program
     1185  case Fri:    // program
    11831186        wallet += pay;
    11841187        `fallthrough;`
    1185   case Sat:  // party
     1188  case Sat:   // party
    11861189        wallet -= party;
    11871190
    11881191  case Sun:  // rest
    11891192
    1190   default:  // error
     1193  default:    // print error
    11911194}
    11921195\end{cfa}
     
    11961199  case Mon: case Tue: case Wed: case Thu:  // program
    11971200        `break;`
    1198   case Fri:  // program
     1201  case Fri:    // program
    11991202        wallet += pay;
    12001203
    1201   case Sat:  // party
     1204  case Sat:   // party
    12021205        wallet -= party;
    12031206        `break;`
    12041207  case Sun:  // rest
    12051208        `break;`
    1206   default:  // error
     1209  default:    // print error
    12071210}
    12081211\end{cfa}
     
    12201223\centering
    12211224\lstDeleteShortInline@%
    1222 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
    1223 \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{non-terminator}}  & \multicolumn{1}{c}{\textbf{target label}}     \\
     1225\begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}}
     1226\multicolumn{1}{c|@{\hspace{\parindentlnth}}}{\textbf{non-terminator}}  & \multicolumn{1}{c}{\textbf{target label}}     \\
    12241227\begin{cfa}
    12251228choose ( ... ) {
     
    12641267\begin{figure}
    12651268\lstDeleteShortInline@%
    1266 \begin{tabular}{@{\hspace{\parindentlnth}}l@{\hspace{\parindentlnth}}l@{\hspace{\parindentlnth}}l@{}}
    1267 \multicolumn{1}{@{\hspace{\parindentlnth}}c@{\hspace{\parindentlnth}}}{\textbf{\CFA}}   & \multicolumn{1}{@{\hspace{\parindentlnth}}c}{\textbf{C}}      \\
     1269\begin{tabular}{@{\hspace{\parindentlnth}}l|@{\hspace{\parindentlnth}}l@{\hspace{\parindentlnth}}l@{}}
     1270\multicolumn{1}{@{\hspace{\parindentlnth}}c|@{\hspace{\parindentlnth}}}{\textbf{\CFA}}  & \multicolumn{1}{@{\hspace{\parindentlnth}}c}{\textbf{C}}      \\
    12681271\begin{cfa}
    12691272`LC:` {
     
    13491352\subsection{Exception Handling}
    13501353
    1351 The following framework for \CFA exception handling is in place, excluding some runtime type-information and virtual functions.
     1354The following framework for \CFA exception-handling is in place, excluding some runtime type-information and virtual functions.
    13521355\CFA provides two forms of exception handling: \newterm{fix-up} and \newterm{recovery} (see Figure~\ref{f:CFAExceptionHandling})~\cite{Buhr92b,Buhr00a}.
    13531356Both mechanisms provide dynamic call to a handler using dynamic name-lookup, where fix-up has dynamic return and recovery has static return from the handler.
     
    13601363\begin{cquote}
    13611364\lstDeleteShortInline@%
    1362 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
    1363 \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{Resumption}}      & \multicolumn{1}{c}{\textbf{Termination}}      \\
     1365\begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}}
     1366\multicolumn{1}{c|@{\hspace{\parindentlnth}}}{\textbf{Resumption}}      & \multicolumn{1}{c}{\textbf{Termination}}      \\
    13641367\begin{cfa}
    13651368`exception R { int fix; };`
     
    14771480If an exception is raised and caught, the handler is run before the finally clause.
    14781481Like a destructor (see Section~\ref{s:ConstructorsDestructors}), a finally clause can raise an exception but not if there is an exception being propagated.
    1479 Mimicking the @finally@ clause with mechanisms like RAII is non-trivially when there are multiple types and local accesses.
     1482Mimicking the @finally@ clause with mechanisms like RAII is non-trivial when there are multiple types and local accesses.
    14801483
    14811484
     
    15301533with ( s, t ) {
    15311534        j + k;                                                                  $\C{// unambiguous, s.j + t.k}$
    1532         m = 5.0;                                                                $\C{// unambiguous, t.m = 5.0}$
    1533         m = 1;                                                                  $\C{// unambiguous, s.m = 1}$
    1534         int a = m;                                                              $\C{// unambiguous, a = s.i }$
    1535         double b = m;                                                   $\C{// unambiguous, b = t.m}$
     1535        m = 5.0;                                                                $\C{// unambiguous, s.m = 5.0}$
     1536        m = 1;                                                                  $\C{// unambiguous, t.m = 1}$
     1537        int a = m;                                                              $\C{// unambiguous, a = t.m }$
     1538        double b = m;                                                   $\C{// unambiguous, b = s.m}$
    15361539        int c = s.i + t.i;                                              $\C{// unambiguous, qualification}$
    1537         (double)m;                                                              $\C{// unambiguous, cast}$
     1540        (double)m;                                                              $\C{// unambiguous, cast s.m}$
    15381541}
    15391542\end{cfa}
     
    15591562and implicitly opened \emph{after} a function-body open, to give them higher priority:
    15601563\begin{cfa}
    1561 void ?{}( S & s, int `i` ) with ( s ) `with( $\emph{\color{red}params}$ )` {
     1564void ?{}( S & s, int `i` ) with ( s ) `{` `with( $\emph{\color{red}params}$ )` {
    15621565        s.i = `i`; j = 3; m = 5.5;
    1563 }
     1566} `}`
    15641567\end{cfa}
    15651568Finally, a cast may be used to disambiguate among overload variables in a @with@ expression:
     
    16601663\begin{cfa}
    16611664`*` int x, y;
    1662 int y;
    1663 \end{cfa}
    1664 &
    1665 \begin{cfa}
    1666 int `*`x, `*`y;
     1665int z;
     1666\end{cfa}
     1667&
     1668\begin{cfa}
     1669int `*`x, `*`y, z;
    16671670
    16681671\end{cfa}
     
    16701673\lstMakeShortInline@%
    16711674\end{cquote}
    1672 The downside of the \CFA semantics is the need to separate regular and pointer declarations.
     1675% The downside of the \CFA semantics is the need to separate regular and pointer declarations.
     1676The separation of regular and pointer declarations by \CFA declarations enforces greater clarity with only slightly more syntax.
    16731677
    16741678\begin{comment}
     
    17921796* [ * int, int ] ( int ) jp;    $\C{// pointer to function returning pointer to int and int with int parameter}$
    17931797\end{cfa}
    1794 Note, a function name cannot be specified:
    1795 \begin{cfa}
    1796 * [ int x ] f () fp;                    $\C{// function name "f" is disallowed}\CRT$
    1797 \end{cfa}
     1798Note, the name of the function pointer is specified last, as for other variable declarations.
    17981799
    17991800Finally, new \CFA declarations may appear together with C declarations in the same program block, but cannot be mixed within a specific declaration.
     
    18521853This provides a much more orthogonal design for library implementors, obviating the need for workarounds such as @std::reference_wrapper@.
    18531854Secondly, \CFA references are rebindable, whereas \CC references have a fixed address.
    1854 \newsavebox{\LstBox}
    1855 \begin{lrbox}{\LstBox}
    1856 \lstset{basicstyle=\footnotesize\linespread{0.9}\sf}
    1857 \begin{cfa}
    1858 int & r = *new( int );
    1859 ...                                                                                     $\C{// non-null reference}$
    1860 delete &r;                                                                      $\C{// unmanaged (programmer) memory-management}$
    1861 r += 1;                                                                         $\C{// undefined reference}$
    1862 \end{cfa}
    1863 \end{lrbox}
    18641855Rebinding allows \CFA references to be default-initialized (\eg to a null pointer\footnote{
    1865 While effort has been made into non-null reference checking in \CC and Java, the exercise seems moot for any non-managed languages (C/\CC), given that it only handles one of many different error situations:
    1866 \begin{cquote}
    1867 \usebox{\LstBox}
    1868 \end{cquote}
    1869 }%
    1870 ) and point to different addresses throughout their lifetime, like pointers.
     1856While effort has been made into non-null reference checking in \CC and Java, the exercise seems moot for any non-managed languages (C/\CC), given that it only handles one of many different error situations, \eg using a pointer after its storage is deleted.}) and point to different addresses throughout their lifetime, like pointers.
    18711857Rebinding is accomplished by extending the existing syntax and semantics of the address-of operator in C.
    18721858
     
    18801866\begin{itemize}
    18811867\item
    1882 if @R@ is an rvalue of type {@T &@$_1 \cdots$@ &@$_r$} where $r \ge 1$ references (@&@ symbols) than @&R@ has type {@T `*`&@$_{\color{red}2} \cdots$@ &@$_{\color{red}r}$}, \\ \ie @T@ pointer with $r-1$ references (@&@ symbols).
     1868if @R@ is an rvalue of type {@T &@$_1 \cdots$@ &@$_r$} where $r \ge 1$ references (@&@ symbols) then @&R@ has type {@T `*`&@$_{\color{red}2} \cdots$@ &@$_{\color{red}r}$}, \\ \ie @T@ pointer with $r-1$ references (@&@ symbols).
    18831869       
    18841870\item
     
    19141900\end{cfa}
    19151901This allows complex values to be succinctly and efficiently passed to functions, without the syntactic overhead of explicit definition of a temporary variable or the runtime cost of pass-by-value.
    1916 \CC allows a similar binding, but only for @const@ references; the more general semantics of \CFA are an attempt to avoid the \newterm{const hell} problem, in which addition of a @const@ qualifier to one reference requires a cascading chain of added qualifiers.
     1902\CC allows a similar binding, but only for @const@ references; the more general semantics of \CFA are an attempt to avoid the \newterm{const poisoning} problem~\cite{Taylor10}, in which addition of a @const@ qualifier to one reference requires a cascading chain of added qualifiers.
    19171903
    19181904
     
    19281914\begin{tabular}{@{}l@{\hspace{3em}}l|l@{}}
    19291915\multicolumn{1}{c@{\hspace{3em}}}{\textbf{C Type Nesting}}      & \multicolumn{1}{c|}{\textbf{C Implicit Hoisting}}     & \multicolumn{1}{c}{\textbf{\CFA}}     \\
    1930 \hline
    19311916\begin{cfa}
    19321917struct S {
     
    22592244        W w, heavy = { 20 };
    22602245        w = 155|_lb|;
    2261         w = 0b1111|_lb|;       // error, binary unsupported
     2246        // binary unsupported
    22622247        w = 0${\color{red}\LstBasicStyle{'}}$233|_lb|;          // quote separator
    22632248        w = 0x9b|_kg|;
     
    23072292\begin{cquote}
    23082293\lstDeleteShortInline@%
    2309 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
    2310 \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{\CFA}}    & \multicolumn{1}{c}{\textbf{C}}        \\
     2294\begin{tabular}{@{}l@{\hspace{\parindentlnth}}l@{}}
     2295\multicolumn{1}{c@{\hspace{\parindentlnth}}}{\textbf{\CFA}}     & \multicolumn{1}{c}{\textbf{C}}        \\
    23112296\begin{cfa}
    23122297MIN
    2313 
    23142298MAX
    2315 
    23162299PI
    23172300E
     
    23192302&
    23202303\begin{cfa}
    2321 SCHAR_MIN, CHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN,
    2322         LLONG_MIN, FLT_MIN, DBL_MIN, LDBL_MIN
    2323 SCHAR_MAX, UCHAR_MAX, SHRT_MAX, INT_MAX, LONG_MAX,
    2324         LLONG_MAX, FLT_MAX, DBL_MAX, LDBL_MAX
     2304CHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, LLONG_MIN, FLT_MIN, DBL_MIN, LDBL_MIN
     2305UCHAR_MAX, SHRT_MAX, INT_MAX, LONG_MAX, LLONG_MAX, FLT_MAX, DBL_MAX, LDBL_MAX
    23252306M_PI, M_PIl
    23262307M_E, M_El
     
    24412422
    24422423\begin{table}
     2424\caption{Storage-Management Operations}
     2425\label{t:StorageManagementOperations}
    24432426\centering
    24442427\lstDeleteShortInline@%
     
    24602443\lstDeleteShortInline~%
    24612444\lstMakeShortInline@%
    2462 \caption{Storage-Management Operations}
    2463 \label{t:StorageManagementOperations}
    24642445\end{table}
    24652446
     
    25892570\end{cquote}
    25902571There is a weak similarity between the \CFA logical-or operator and the Shell pipe-operator for moving data, where data flows in the correct direction for input but the opposite direction for output.
    2591 
     2572\begin{comment}
    25922573The implicit separator character (space/blank) is a separator not a terminator.
    25932574The rules for implicitly adding the separator are:
     
    26082589}%
    26092590\end{itemize}
     2591\end{comment}
    26102592There are functions to set and get the separator string, and manipulators to toggle separation on and off in the middle of output.
    26112593
     
    26562638
    26572639
    2658 \section{Evaluation}
     2640\section{Polymorphic Evaluation}
    26592641\label{sec:eval}
    26602642
    2661 Though \CFA provides significant added functionality over C, these features have a low runtime penalty.
    2662 In fact, \CFA's features for generic programming can enable faster runtime execution than idiomatic @void *@-based C code.
    2663 This claim is demonstrated through a set of generic-code-based micro-benchmarks in C, \CFA, and \CC (see stack implementations in Appendix~\ref{sec:BenchmarkStackImplementations}).
     2643\CFA adds parametric polymorphism to C.
     2644A runtime evaluation is performed to compare the cost of alternative styles of polymorphism.
     2645The goal is to compare just the underlying mechanism for implementing different kinds of polymorphism.
     2646% Though \CFA provides significant added functionality over C, these features have a low runtime penalty.
     2647% In fact, it is shown that \CFA's generic programming can enable faster runtime execution than idiomatic @void *@-based C code.
     2648The experiment is a set of generic-stack micro-benchmarks~\cite{CFAStackEvaluation} in C, \CFA, and \CC (see implementations in Appendix~\ref{sec:BenchmarkStackImplementations}).
    26642649Since all these languages share a subset essentially comprising standard C, maximal-performance benchmarks should show little runtime variance, differing only in length and clarity of source code.
    26652650A more illustrative comparison measures the costs of idiomatic usage of each language's features.
     
    26922677\end{figure}
    26932678
    2694 The structure of each benchmark implemented is: C with @void *@-based polymorphism, \CFA with the presented features, \CC with templates, and \CC using only class inheritance for polymorphism, called \CCV.
     2679The structure of each benchmark implemented is: C with @void *@-based polymorphism, \CFA with parametric polymorphism, \CC with templates, and \CC using only class inheritance for polymorphism, called \CCV.
    26952680The \CCV variant illustrates an alternative object-oriented idiom where all objects inherit from a base @object@ class, mimicking a Java-like interface;
    26962681hence runtime checks are necessary to safely down-cast objects.
    26972682The most notable difference among the implementations is in memory layout of generic types: \CFA and \CC inline the stack and pair elements into corresponding list and pair nodes, while C and \CCV lack such a capability and instead must store generic objects via pointers to separately-allocated objects.
    2698 Note that the C benchmark uses unchecked casts as there is no runtime mechanism to perform such checks, while \CFA and \CC provide type-safety statically.
     2683Note, the C benchmark uses unchecked casts as C has no runtime mechanism to perform such checks, while \CFA and \CC provide type-safety statically.
    26992684
    27002685Figure~\ref{fig:eval} and Table~\ref{tab:eval} show the results of running the benchmark in Figure~\ref{fig:BenchmarkTest} and its C, \CC, and \CCV equivalents.
     
    27112696
    27122697\begin{table}
    2713 \centering
    27142698\caption{Properties of benchmark code}
    27152699\label{tab:eval}
     2700\centering
    27162701\newcommand{\CT}[1]{\multicolumn{1}{c}{#1}}
    27172702\begin{tabular}{rrrrr}
     
    27262711The C and \CCV variants are generally the slowest with the largest memory footprint, because of their less-efficient memory layout and the pointer-indirection necessary to implement generic types;
    27272712this inefficiency is exacerbated by the second level of generic types in the pair benchmarks.
    2728 By contrast, the \CFA and \CC variants run in roughly equivalent time for both the integer and pair of @short@ and @char@ because the storage layout is equivalent, with the inlined libraries (\ie no separate compilation) and greater maturity of the \CC compiler contributing to its lead.
     2713By contrast, the \CFA and \CC variants run in roughly equivalent time for both the integer and pair because of equivalent storage layout, with the inlined libraries (\ie no separate compilation) and greater maturity of the \CC compiler contributing to its lead.
    27292714\CCV is slower than C largely due to the cost of runtime type-checking of down-casts (implemented with @dynamic_cast@);
    2730 The outlier in the graph for \CFA, pop @pair@, results from the complexity of the generated-C polymorphic code.
    2731 The gcc compiler is unable to optimize some dead code and condense nested calls; a compiler designed for \CFA could easily perform these optimizations.
     2715The outlier for \CFA, pop @pair@, results from the complexity of the generated-C polymorphic code.
     2716The gcc compiler is unable to optimize some dead code and condense nested calls;
     2717a compiler designed for \CFA could easily perform these optimizations.
    27322718Finally, the binary size for \CFA is larger because of static linking with the \CFA libraries.
    27332719
     
    27462732The \CFA benchmark is able to eliminate all redundant type annotations through use of the polymorphic @alloc@ function discussed in Section~\ref{sec:libraries}.
    27472733
     2734We conjecture these results scale across most generic data-types as the underlying polymorphic implement is constant.
     2735
    27482736
    27492737\section{Related Work}
     
    27512739
    27522740\subsection{Polymorphism}
     2741
     2742ML~\cite{ML} was the first language to support parametric polymorphism.
     2743Like \CFA, it supports universal type parameters, but not the use of assertions and traits to constrain type arguments.
     2744Haskell~\cite{Haskell10} combines ML-style polymorphism, polymorphic data types, and type inference with the notion of type classes, collections of overloadable methods that correspond in intent to traits in \CFA.
     2745Unlike \CFA, Haskell requires an explicit association between types and their classes that specifies the implementation of operations.
     2746These associations determine the functions that are assertion arguments for particular combinations of class and type, in contrast to \CFA where the assertion arguments are selected at function call sites based upon the set of operations in scope at that point.
     2747Haskell also severely restricts the use of overloading: an overloaded name can only be associated with a single class, and methods with overloaded names can only be defined as part of instance declarations.
    27532748
    27542749\CC provides three disjoint polymorphic extensions to C: overloading, inheritance, and templates.
     
    28042799Go does not have tuples but supports MRVF.
    28052800Java's variadic functions appear similar to C's but are type-safe using homogeneous arrays, which are less useful than \CFA's heterogeneously-typed variadic functions.
    2806 Tuples are a fundamental abstraction in most functional programming languages, such as Standard ML~\cite{sml} and~\cite{Scala}, which decompose tuples using pattern matching.
     2801Tuples are a fundamental abstraction in most functional programming languages, such as Standard ML~\cite{sml}, Haskell, and Scala~\cite{Scala}, which decompose tuples using pattern matching.
    28072802
    28082803
     
    28352830Finally, we demonstrate that \CFA performance for some idiomatic cases is better than C and close to \CC, showing the design is practically applicable.
    28362831
    2837 There is ongoing work on a wide range of \CFA features, including arrays with size, runtime type-information, virtual functions, user-defined conversions, concurrent primitives, and modules.
    2838 While all examples in the paper compile and run, a public beta-release of \CFA will take another 8--12 months to finalize these extensions.
    2839 There are also interesting future directions for the polymorphism design.
    2840 Notably, \CC template functions trade compile time and code bloat for optimal runtime of individual instantiations of polymorphic functions.
    2841 \CFA polymorphic functions use dynamic virtual-dispatch;
    2842 the runtime overhead of this approach is low, but not as low as inlining, and it may be beneficial to provide a mechanism for performance-sensitive code.
     2832While all examples in the paper compile and run, a public beta-release of \CFA will take 6--8 months to reduce compilation time, provide better debugging, and add a few more libraries.
     2833There is also new work on a number of \CFA features, including arrays with size, runtime type-information, virtual functions, user-defined conversions, and modules.
     2834While \CFA polymorphic functions use dynamic virtual-dispatch with low runtime overhead (see Section~\ref{sec:eval}), it is not as low as \CC template-inlining.
     2835Hence it may be beneficial to provide a mechanism for performance-sensitive code.
    28432836Two promising approaches are an @inline@ annotation at polymorphic function call sites to create a template-specialization of the function (provided the code is visible) or placing an @inline@ annotation on polymorphic function-definitions to instantiate a specialized version for some set of types (\CC template specialization).
    28442837These approaches are not mutually exclusive and allow performance optimizations to be applied only when necessary, without suffering global code-bloat.
     
    28492842
    28502843The authors would like to recognize the design assistance of Glen Ditchfield, Richard Bilson, Thierry Delisle, Andrew Beach and Brice Dobry on the features described in this paper, and thank Magnus Madsen for feedback on the writing.
    2851 This work is supported by a corporate partnership with Huawei Ltd.\ (\url{http://www.huawei.com}), and Aaron Moss and Peter Buhr are partially funded by the Natural Sciences and Engineering Research Council of Canada.
    2852 
    2853 
     2844Funding for this project has been provided by Huawei Ltd.\ (\url{http://www.huawei.com}), and Aaron Moss and Peter Buhr are partially funded by the Natural Sciences and Engineering Research Council of Canada.
     2845
     2846{%
     2847\fontsize{9bp}{12bp}\selectfont%
    28542848\bibliography{pl}
    2855 
     2849}%
    28562850
    28572851\appendix
  • doc/papers/general/evaluation/timing.gp

    r14a61b5 r5fec3f6  
    2525
    2626set label "23.9" at 7.125,10.5
    27 
     27set style fill pattern 4 border lt -1
    2828# set datafile separator ","
    2929plot for [COL=2:5] 'evaluation/timing.dat' using (column(COL)/SCALE):xticlabels(1) title columnheader
  • src/main.cc

    r14a61b5 r5fec3f6  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun May  6 22:25:59 2018
    13 // Update Count     : 491
     12// Last Modified On : Mon May  7 14:35:57 2018
     13// Update Count     : 492
    1414//
    1515
     
    407407        opterr = 0;                                                                                     // (global) prevent getopt from printing error messages
    408408
    409         bool Werror = false;
     409        bool Wsuppress = false, Werror = false;
    410410        int c;
    411411        while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) {
     
    495495                        break;
    496496                  case 'w':
    497                         SemanticWarning_SuppressAll();
     497                        Wsuppress = true;
    498498                        break;
    499499                  case 'W':
     
    545545                SemanticWarning_WarningAsError();
    546546        } // if
     547        if ( Wsuppress ) {
     548                SemanticWarning_SuppressAll();
     549        } // if
    547550        // for ( const auto w : WarningFormats ) {
    548551        //      cout << w.name << ' ' << (int)w.severity << endl;
Note: See TracChangeset for help on using the changeset viewer.