Changeset cfc3e0f


Ignore:
Timestamp:
May 7, 2018, 1:40:24 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
c5e5109
Parents:
01ff4e1
Message:

referee responses

Location:
doc
Files:
1 added
8 edited
1 moved

Legend:

Unmodified
Added
Removed
  • doc/bibliography/pl.bib

    r01ff4e1 rcfc3e0f  
    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

    r01ff4e1 rcfc3e0f  
    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

    r01ff4e1 rcfc3e0f  
    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

    r01ff4e1 rcfc3e0f  
    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

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

    r01ff4e1 rcfc3e0f  
    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

    r01ff4e1 rcfc3e0f  
    174174\lstMakeShortInline@%
    175175
     176\let\OLDthebibliography\thebibliography
     177\renewcommand\thebibliography[1]{
     178  \OLDthebibliography{#1}
     179  \setlength{\parskip}{0pt}
     180  \setlength{\itemsep}{4pt plus 0.3ex}
     181}
    176182
    177183\title{\texorpdfstring{\protect\CFA : Adding Modern Programming Language Features to C}{Cforall : Adding Modern Programming Language Features to C}}
     
    191197The 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.
    192198This 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.
     199Nevertheless, C, first standardized almost fourty years ago, lacks many features that make programming in more modern languages safer and more productive.
     200
     201The 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.
    195202Prior 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.
    196203Specifically, \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.
     
    226233Love it or hate it, C is extremely popular, highly used, and one of the few systems languages.
    227234In 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.
     235Nevertheless, C, first standardized almost fourty years ago~\cite{ANSI89:C}, lacks many features that make programming in more modern languages safer and more productive.
    229236
    230237\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.
     
    324331int max( int a, int b ) { return a < b ? b : a; }  $\C{// (3)}$
    325332double 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}$
     333max( 7, -max );                                         $\C{// uses (3) and (1), by matching int from constant 7}$
    327334max( 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$
     335max( max, -max );                                       $\C{// ERROR, ambiguous}$
     336int m = max( max, -max );                       $\C{// uses (3) and (1) twice, by matching return type}$
    330337\end{cfa}
    331338
     
    336343As 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.
    337344
    338 \Celeven added @_Generic@ expressions, which is used in preprocessor macros to provide a form of ad-hoc polymorphism;
     345\Celeven added @_Generic@ expressions~\cite[\S~6.5.1.1]{C11}, which is used with preprocessor macros to provide ad-hoc polymorphism;
    339346however, this polymorphism is both functionally and ergonomically inferior to \CFA name overloading.
    340347The macro wrapping the generic expression imposes some limitations;
     
    369376\begin{cfa}
    370377forall( otype T `| { T ?+?(T, T); }` ) T twice( T x ) { return x `+` x; }  $\C{// ? denotes operands}$
    371 int val = twice( twice( 3.7 ) );
     378int val = twice( twice( 3.7 ) );  $\C{// val == 14}$
    372379\end{cfa}
    373380which works for any type @T@ with a matching addition operator.
    374381The 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@.
    375382There 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@.
     383The first approach has a late conversion from @double@ to @int@ on the final assignment, while the second has an early conversion to @int@.
    377384\CFA minimizes the number of conversions and their potential to lose information, so it selects the first approach, which corresponds with C-programmer intuition.
    378385
     
    420427\begin{cfa}
    421428forall( otype T | { int ?<?( T, T ); } ) void qsort( const T * arr, size_t size ) { /* use C qsort */ }
    422 {
     429int main() {
    423430        int ?<?( double x, double y ) { return x `>` y; } $\C{// locally override behaviour}$
    424         qsort( vals, size );                                    $\C{// descending sort}$
     431        qsort( vals, 10 );                                                      $\C{// descending sort}$
    425432}
    426433\end{cfa}
     
    534541\begin{cquote}
    535542\lstDeleteShortInline@%
    536 \begin{tabular}{@{}l|@{\hspace{2\parindentlnth}}l@{}}
     543\begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}}
    537544\begin{cfa}
    538545forall( otype R, otype S ) struct pair {
     
    578585\begin{cfa}
    579586struct _pair_conc0 {
    580         const char * first;
    581         int second;
     587        const char * first;  int second;
    582588};
    583589\end{cfa}
     
    587593\begin{cfa}
    588594struct _pair_conc1 {
    589         void * first;
    590         void * second;
     595        void * first, * second;
    591596};
    592597\end{cfa}
     
    645650\begin{cquote}
    646651\lstDeleteShortInline@%
    647 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
     652\begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}}
    648653\begin{cfa}
    649654forall( dtype Unit ) struct scalar { unsigned long value; };
     
    661666                                                        half_marathon;
    662667scalar(litres) two_pools = pool + pool;
    663 `marathon + pool;`      // compilation ERROR
     668`marathon + pool;`      // ERROR, mismatched types
    664669\end{cfa}
    665670\end{tabular}
     
    10061011\begin{cfa}
    10071012forall( 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;
     1013        T0 field_0;  T1 field_1;                                        $\C{// generated before the first 2-tuple}$
    10101014};
    10111015_tuple2(int, int) f() {
    10121016        _tuple2(double, double) x;
    10131017        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;
     1018                T0 field_0;  T1 field_1;  T2 field_2;   $\C{// generated before the first 3-tuple}$
    10171019        };
    10181020        _tuple3(int, double, int) y;
    10191021}
    10201022\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}%
     1023Tuple expressions are then converted directly into compound literals, \eg @[5, 'x', 1.24]@ becomes @(_tuple3(int, char,@ @double)){ 5, 'x', 1.24 }@.
    10241024
    10251025\begin{comment}
     
    11051105\begin{cquote}
    11061106\lstDeleteShortInline@%
    1107 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
     1107\begin{tabular}{@{}l|@{\hspace{2\parindentlnth}}l@{}}
    11081108\multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{\CFA}}    & \multicolumn{1}{c}{\textbf{C}}        \\
    11091109\begin{cfa}
     
    11741174\centering
    11751175\lstDeleteShortInline@%
    1176 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
    1177 \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{\CFA}}    & \multicolumn{1}{c}{\textbf{C}}        \\
     1176\begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}}
     1177\multicolumn{1}{c|@{\hspace{\parindentlnth}}}{\textbf{\CFA}}    & \multicolumn{1}{c}{\textbf{C}}        \\
    11781178\begin{cfa}
    11791179`choose` ( day ) {
     
    12201220\centering
    12211221\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}}     \\
     1222\begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}}
     1223\multicolumn{1}{c|@{\hspace{\parindentlnth}}}{\textbf{non-terminator}}  & \multicolumn{1}{c}{\textbf{target label}}     \\
    12241224\begin{cfa}
    12251225choose ( ... ) {
     
    12641264\begin{figure}
    12651265\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}}      \\
     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}}      \\
    12681268\begin{cfa}
    12691269`LC:` {
     
    13491349\subsection{Exception Handling}
    13501350
    1351 The following framework for \CFA exception handling is in place, excluding some runtime type-information and virtual functions.
     1351The following framework for \CFA exception-handling is in place, excluding some runtime type-information and virtual functions.
    13521352\CFA provides two forms of exception handling: \newterm{fix-up} and \newterm{recovery} (see Figure~\ref{f:CFAExceptionHandling})~\cite{Buhr92b,Buhr00a}.
    13531353Both 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.
     
    13601360\begin{cquote}
    13611361\lstDeleteShortInline@%
    1362 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
    1363 \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{Resumption}}      & \multicolumn{1}{c}{\textbf{Termination}}      \\
     1362\begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}}
     1363\multicolumn{1}{c|@{\hspace{\parindentlnth}}}{\textbf{Resumption}}      & \multicolumn{1}{c}{\textbf{Termination}}      \\
    13641364\begin{cfa}
    13651365`exception R { int fix; };`
     
    18521852This provides a much more orthogonal design for library implementors, obviating the need for workarounds such as @std::reference_wrapper@.
    18531853Secondly, \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}
    18641854Rebinding 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.
     1855While 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.
    18711856Rebinding is accomplished by extending the existing syntax and semantics of the address-of operator in C.
    18721857
     
    18801865\begin{itemize}
    18811866\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).
     1867if @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).
    18831868       
    18841869\item
     
    19141899\end{cfa}
    19151900This 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.
     1901\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.
    19171902
    19181903
     
    19281913\begin{tabular}{@{}l@{\hspace{3em}}l|l@{}}
    19291914\multicolumn{1}{c@{\hspace{3em}}}{\textbf{C Type Nesting}}      & \multicolumn{1}{c|}{\textbf{C Implicit Hoisting}}     & \multicolumn{1}{c}{\textbf{\CFA}}     \\
    1930 \hline
    19311915\begin{cfa}
    19321916struct S {
     
    22592243        W w, heavy = { 20 };
    22602244        w = 155|_lb|;
    2261         w = 0b1111|_lb|;       // error, binary unsupported
     2245        // binary unsupported
    22622246        w = 0${\color{red}\LstBasicStyle{'}}$233|_lb|;          // quote separator
    22632247        w = 0x9b|_kg|;
     
    23072291\begin{cquote}
    23082292\lstDeleteShortInline@%
    2309 \begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
    2310 \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{\CFA}}    & \multicolumn{1}{c}{\textbf{C}}        \\
     2293\begin{tabular}{@{}l@{\hspace{\parindentlnth}}l@{}}
     2294\multicolumn{1}{c@{\hspace{\parindentlnth}}}{\textbf{\CFA}}     & \multicolumn{1}{c}{\textbf{C}}        \\
    23112295\begin{cfa}
    23122296MIN
    2313 
    23142297MAX
    2315 
    23162298PI
    23172299E
     
    23192301&
    23202302\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
     2303CHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, LLONG_MIN, FLT_MIN, DBL_MIN, LDBL_MIN
     2304UCHAR_MAX, SHRT_MAX, INT_MAX, LONG_MAX, LLONG_MAX, FLT_MAX, DBL_MAX, LDBL_MAX
    23252305M_PI, M_PIl
    23262306M_E, M_El
     
    24412421
    24422422\begin{table}
     2423\caption{Storage-Management Operations}
     2424\label{t:StorageManagementOperations}
    24432425\centering
    24442426\lstDeleteShortInline@%
     
    24602442\lstDeleteShortInline~%
    24612443\lstMakeShortInline@%
    2462 \caption{Storage-Management Operations}
    2463 \label{t:StorageManagementOperations}
    24642444\end{table}
    24652445
     
    25892569\end{cquote}
    25902570There 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 
     2571\begin{comment}
    25922572The implicit separator character (space/blank) is a separator not a terminator.
    25932573The rules for implicitly adding the separator are:
     
    26082588}%
    26092589\end{itemize}
     2590\end{comment}
    26102591There are functions to set and get the separator string, and manipulators to toggle separation on and off in the middle of output.
    26112592
     
    26562637
    26572638
    2658 \section{Evaluation}
     2639\section{Polymorphism Evaluation}
    26592640\label{sec:eval}
    26602641
    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}).
     2642\CFA adds parametric polymorphism to C.
     2643A runtime evaluation is performed to compare the cost of alternative styles of polymorphism.
     2644The goal is to compare just the underlying mechanism for implementing different kinds of polymorphism.
     2645% Though \CFA provides significant added functionality over C, these features have a low runtime penalty.
     2646% In fact, it is shown that \CFA's generic programming can enable faster runtime execution than idiomatic @void *@-based C code.
     2647The experiment is a set of generic-stack micro-benchmarks~\cite{CFAStackEvaluation} in C, \CFA, and \CC (see implementations in Appendix~\ref{sec:BenchmarkStackImplementations}).
    26642648Since 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.
    26652649A more illustrative comparison measures the costs of idiomatic usage of each language's features.
     
    26922676\end{figure}
    26932677
    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.
     2678The 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.
    26952679The \CCV variant illustrates an alternative object-oriented idiom where all objects inherit from a base @object@ class, mimicking a Java-like interface;
    26962680hence runtime checks are necessary to safely down-cast objects.
    26972681The 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.
     2682Note, the C benchmark uses unchecked casts as C has no runtime mechanism to perform such checks, while \CFA and \CC provide type-safety statically.
    26992683
    27002684Figure~\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.
     
    27112695
    27122696\begin{table}
    2713 \centering
    27142697\caption{Properties of benchmark code}
    27152698\label{tab:eval}
     2699\centering
    27162700\newcommand{\CT}[1]{\multicolumn{1}{c}{#1}}
    27172701\begin{tabular}{rrrrr}
     
    27262710The 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;
    27272711this 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.
     2712By 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.
    27292713\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.
     2714The outlier for \CFA, pop @pair@, results from the complexity of the generated-C polymorphic code.
     2715The gcc compiler is unable to optimize some dead code and condense nested calls;
     2716a compiler designed for \CFA could easily perform these optimizations.
    27322717Finally, the binary size for \CFA is larger because of static linking with the \CFA libraries.
    27332718
     
    27462731The \CFA benchmark is able to eliminate all redundant type annotations through use of the polymorphic @alloc@ function discussed in Section~\ref{sec:libraries}.
    27472732
     2733We conjecture these results scale across most generic data-types as the underlying polymorphic implement is constant.
     2734
    27482735
    27492736\section{Related Work}
     
    27512738
    27522739\subsection{Polymorphism}
     2740
     2741ML~\cite{ML} was the first language to support parametric polymorphism.
     2742Like \CFA, it supports universal type parameters, but not the use of assertions and traits to constrain type arguments.
     2743Haskell~\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.
     2744Unlike \CFA, Haskell requires an explicit association between types and their classes that specifies the implementation of operations.
     2745These 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.
     2746Haskell 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.
    27532747
    27542748\CC provides three disjoint polymorphic extensions to C: overloading, inheritance, and templates.
     
    28042798Go does not have tuples but supports MRVF.
    28052799Java'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.
     2800Tuples 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.
    28072801
    28082802
     
    28352829Finally, we demonstrate that \CFA performance for some idiomatic cases is better than C and close to \CC, showing the design is practically applicable.
    28362830
    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.
     2831While 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.
     2832There is also new work on a number of \CFA features, including arrays with size, runtime type-information, virtual functions, user-defined conversions, and modules.
     2833While \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.
     2834Hence it may be beneficial to provide a mechanism for performance-sensitive code.
    28432835Two 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).
    28442836These approaches are not mutually exclusive and allow performance optimizations to be applied only when necessary, without suffering global code-bloat.
     
    28492841
    28502842The 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 
     2843Funding 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.
     2844
     2845{%
     2846\fontsize{9bp}{12bp}\selectfont%
    28542847\bibliography{pl}
    2855 
     2848}%
    28562849
    28572850\appendix
  • doc/papers/general/evaluation/timing.gp

    r01ff4e1 rcfc3e0f  
    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
Note: See TracChangeset for help on using the changeset viewer.