Changeset 5fec3f6
- Timestamp:
- May 8, 2018, 11:55:44 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, 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. - Files:
-
- 1 added
- 1 deleted
- 9 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
doc/bibliography/pl.bib
r14a61b5 r5fec3f6 40 40 % @string{mathann="Math. Ann."} 41 41 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 42 50 % A 43 51 … … 782 790 howpublished= {\href{http://www.boost.org/doc/libs/1_61_0/libs/coroutine/doc/html/index.html} 783 791 {{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}, 785 793 } 786 794 … … 855 863 keywords = {ANSI C 89}, 856 864 contributer = {gjditchfield@plg}, 857 title = {American National Standard for Information Systems -- Programming Language -- {C}}, 865 author = {C90}, 866 title = {Programming Languages -- {C}}, 858 867 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} 863 871 } 864 872 … … 888 896 title = {\textsf{C}{$\mathbf{\forall}$} Features}, 889 897 howpublished= {\url{https://plg.uwaterloo.ca/~cforall/features}}, 890 note = {Accessed: 2018-01-01},898 optnote = {Accessed: 2018-01-01}, 891 899 } 892 900 … … 1640 1648 } 1641 1649 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 1642 1662 @phdthesis{Ditchfield92, 1643 1663 keywords = {C, parametric polymorphism, overloading}, … … 2755 2775 @misc{GCCExtensions, 2756 2776 contributer = {a3moss@uwaterloo.ca}, 2757 key = { {GNU}},2777 key = {C Extensions}, 2758 2778 author = {{C Extensions}}, 2759 2779 title = {Extensions to the {C} Language Family}, 2760 2780 year = 2014, 2761 2781 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}, 2763 2783 } 2764 2784 … … 3137 3157 year = 2014, 3138 3158 howpublished= {https://developer.gnome.org/gobject/stable/}, 3139 note = {Accessed: 2017-04},3159 optnote = {Accessed: 2017-04}, 3140 3160 } 3141 3161 … … 3209 3229 3210 3230 % 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 } 3211 3241 3212 3242 @article{Michael04a, … … 3760 3790 keywords = {concurrency, critical section}, 3761 3791 contributer = {pabuhr@plg}, 3762 author = {Dominic Duggan and G ordonV. Cormack and John Ophel},3792 author = {Dominic Duggan and G. V. Cormack and John Ophel}, 3763 3793 title = {Kinded Type Inference for Parametric Overloading}, 3764 3794 journal = acta, … … 4685 4715 year = 2015, 4686 4716 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} 4688 4718 } 4689 4719 … … 4695 4725 year = 2015, 4696 4726 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} 4698 4728 } 4699 4729 … … 5757 5787 keywords = {Cyclone, existential types, polymorphism, type variables}, 5758 5788 contributer = {a3moss@plg}, 5759 author = {D anGrossman},5789 author = {D. Grossman}, 5760 5790 title = {Quantified Types in an Imperative Language}, 5761 5791 journal = toplas, … … 6762 6792 title = {{TIOBE} Index}, 6763 6793 howpublished= {\href{http://www.tiobe.com/tiobe_index}{http://\-www.tiobe.com/\-tiobe\_index}}, 6764 note = {Accessed: 2018-09},6794 optnote = {Accessed: 2018-09}, 6765 6795 } 6766 6796 … … 7087 7117 year = 2017, 7088 7118 howpublished= {\url{https://wiki.gnome.org/Projects/Vala/Manual}}, 7089 note = {Accessed: 2017-04}7119 optnote = {Accessed: 2017-04} 7090 7120 } 7091 7121 -
doc/papers/AMA/AMA-stix/Documents/README.txt
r14a61b5 r5fec3f6 13 13 % NJDnatbib.sty --> NJD natbib reference package. 14 14 % 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) 23 16 % Still shows font error, please do the following 24 17 % Start-->run--> type "mo_edmin.exe" and press enter -
doc/papers/AMA/AMA-stix/ama/WileyNJD-AMA.bst
r14a61b5 r5fec3f6 502 502 editor empty$ 503 503 { booktitle emphasize * } 504 504 { " " * format.editors * " " * booktitle emphasize * ", " * } 505 505 if$ 506 506 } … … 691 691 { format.journal emphasize "journal" output.check 692 692 format.date add.semicolon "year" output.check 693 blank.sep 693 694 format.volume output 694 695 format.number output … … 824 825 new.block 825 826 format.pages output 827 new.block 826 828 organization output 829 new.block 827 830 publisher output 828 831 inproformat.date "year" output.check … … 863 866 { new.block organization new.block address new.block.checkb 864 867 organization output 868 new.block 865 869 address output 866 870 } … … 883 887 new.block 884 888 school "school" output.check 889 new.block 885 890 address output 886 891 format.date "year" output.check … … 927 932 "PhD thesis" format.thesis.type output.nonnull 928 933 school "school" output.check 934 new.block 929 935 address output 930 936 format.date "year" output.check -
doc/papers/AMA/AMA-stix/ama/WileyNJD-v2.cls
r14a61b5 r5fec3f6 484 484 \if@STIXLargeOneCol% 485 485 \RequirePackage[not1,notextcomp,lcgreekalpha]{stix}% 486 %\usepackage[scaled]{helvet}487 %\renewcommand\familydefault{\sfdefault}488 486 \usepackage[T1]{fontenc} 489 487 \BXhsize=170mm% … … 528 526 %\RequirePackage[not1,notextcomp,lcgreekalpha]{stix}% 529 527 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 } 535 533 536 534 \renewcommand\figurename{\textbf{FIGURE}}%% … … 1414 1412 \gdef\@stix@font@defn{% 1415 1413 % 1416 %\def\infoboxfont{\fontfamily{tim}\fontsize{8}{8}\selectfont}%1414 \def\infoboxfont{\fontfamily{tim}\fontsize{8}{8}\selectfont}% 1417 1415 % 1418 %\def\watermarkfont{\reset@font\fontfamily{\ffdefault}\fontsize{45}{45}\bfseries\selectfont}1416 \def\watermarkfont{\reset@font\fontfamily{\ffdefault}\fontsize{45}{45}\bfseries\selectfont} 1419 1417 % 1420 1418 \def\pagenumfont{\rmfamily\fontsize{7}{9}\bfseries\selectfont}% … … 1429 1427 \def\arttypefont{\rmfamily\fontsize{9}{9}\fontseries{b}\selectfont}% 1430 1428 \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}% 1432 1430 \def\subtitlefont{\rmfamily\fontsize{16}{21}\bfseries\selectfont\leftskip\z@\rightskip\z@ plus1fil}% 1433 1431 \def\Authorfont{\rmfamily\fontsize{12}{18}\selectfont\leftskip\z@\rightskip\z@ plus1fil}% … … 1484 1482 \gdef\@lato@font@defn{% 1485 1483 % 1486 %\def\infoboxfont{\fontfamily{tim}\fontsize{8}{8}\selectfont}%1484 \def\infoboxfont{\fontfamily{tim}\fontsize{8}{8}\selectfont}% 1487 1485 % 1488 %\def\watermarkfont{\reset@font\fontfamily{\ffdefault}\fontsize{45}{45}\bfseries\selectfont}1486 \def\watermarkfont{\reset@font\fontfamily{\ffdefault}\fontsize{45}{45}\bfseries\selectfont} 1489 1487 % 1490 1488 \def\pagenumfont{\rmfamily\fontsize{7}{9}\bfseries\selectfont}% … … 3249 3247 \fi 3250 3248 \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 }% 3253 3251 \renewcommand\theequation{\@Alph\c@section\arabic{equation}}% 3254 3252 }{% -
doc/papers/general/.gitignore
r14a61b5 r5fec3f6 8 8 Paper.out.ps 9 9 WileyNJD-AMA.bst 10 evaluation.zip -
doc/papers/general/Makefile
r14a61b5 r5fec3f6 45 45 @rm -frv ${DOCUMENT} ${BASE}.ps WileyNJD-AMA.bst ${BASE}.out.ps ${Build} 46 46 47 evaluation.zip : 48 zip -x evaluation/.gitignore -x evaluation/timing.xlsx -x evaluation/timing.dat -r evaluation.zip evaluation 49 47 50 # File Dependencies # 48 51 … … 66 69 ## Define the default recipes. 67 70 68 ${Build} :71 ${Build} : 69 72 mkdir -p ${Build} 70 73 71 ${BASE}.out.ps : ${Build}74 ${BASE}.out.ps : ${Build} 72 75 ln -fs ${Build}/Paper.out.ps . 73 76 74 WileyNJD-AMA.bst :77 WileyNJD-AMA.bst : 75 78 ln -fs ../AMA/AMA-stix/ama/WileyNJD-AMA.bst . 76 79 -
doc/papers/general/Paper.tex
r14a61b5 r5fec3f6 59 59 %\DeclareTextCommandDefault{\textunderscore}{\leavevmode\makebox[1.2ex][c]{\rule{1ex}{0.1ex}}} 60 60 \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}} 61 64 62 65 \makeatletter … … 174 177 \lstMakeShortInline@% 175 178 179 \let\OLDthebibliography\thebibliography 180 \renewcommand\thebibliography[1]{ 181 \OLDthebibliography{#1} 182 \setlength{\parskip}{0pt} 183 \setlength{\itemsep}{4pt plus 0.3ex} 184 } 176 185 177 186 \title{\texorpdfstring{\protect\CFA : Adding Modern Programming Language Features to C}{Cforall : Adding Modern Programming Language Features to C}} … … 191 200 The 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. 192 201 This 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. 202 Nevertheless, C, first standardized almost forty years ago, lacks many features that make programming in more modern languages safer and more productive. 203 204 The 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. 195 205 Prior 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. 196 206 Specifically, \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. … … 226 236 Love it or hate it, C is extremely popular, highly used, and one of the few systems languages. 227 237 In 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.238 Nevertheless, C, first standardized almost forty years ago~\cite{ANSI89:C}, lacks many features that make programming in more modern languages safer and more productive. 229 239 230 240 \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. … … 292 302 The \CFA tests are 290+ files and 27,000+ lines of code. 293 303 The 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+).304 The tests check for correctness and are used for daily regression testing of 3800+ commits. 295 305 296 306 Finally, it is impossible to describe a programming language without usages before definitions. … … 324 334 int max( int a, int b ) { return a < b ? b : a; } $\C{// (3)}$ 325 335 double 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}$336 max( 7, -max ); $\C{// uses (3) and (1), by matching int from constant 7}$ 327 337 max( 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$338 max( max, -max ); $\C{// ERROR, ambiguous}$ 339 int m = max( max, -max ); $\C{// uses (3) and (1) twice, by matching return type}$ 330 340 \end{cfa} 331 341 … … 336 346 As 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. 337 347 338 \Celeven added @_Generic@ expressions , which is used in preprocessor macros to provide a form ofad-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; 339 349 however, this polymorphism is both functionally and ergonomically inferior to \CFA name overloading. 340 350 The macro wrapping the generic expression imposes some limitations; 341 351 \eg, it cannot implement the example above, because the variables @max@ are ambiguous with the functions @max@. 342 352 Ergonomic 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} 344 354 345 355 % http://fanf.livejournal.com/144696.html … … 369 379 \begin{cfa} 370 380 forall( otype T `| { T ?+?(T, T); }` ) T twice( T x ) { return x `+` x; } $\C{// ? denotes operands}$ 371 int val = twice( twice( 3.7 ) ); 381 int val = twice( twice( 3.7 ) ); $\C{// val == 14}$ 372 382 \end{cfa} 373 383 which works for any type @T@ with a matching addition operator. 374 384 The 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@. 375 385 There 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 ea gerconversion to @int@.386 The first approach has a late conversion from @double@ to @int@ on the final assignment, while the second has an early conversion to @int@. 377 387 \CFA minimizes the number of conversions and their potential to lose information, so it selects the first approach, which corresponds with C-programmer intuition. 378 388 … … 420 430 \begin{cfa} 421 431 forall( otype T | { int ?<?( T, T ); } ) void qsort( const T * arr, size_t size ) { /* use C qsort */ } 422 {432 int main() { 423 433 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}$ 425 435 } 426 436 \end{cfa} … … 534 544 \begin{cquote} 535 545 \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 { 539 549 R first; S second; 540 550 }; … … 578 588 \begin{cfa} 579 589 struct _pair_conc0 { 580 const char * first; 581 int second; 590 const char * first; int second; 582 591 }; 583 592 \end{cfa} … … 587 596 \begin{cfa} 588 597 struct _pair_conc1 { 589 void * first; 590 void * second; 598 void * first, * second; 591 599 }; 592 600 \end{cfa} … … 645 653 \begin{cquote} 646 654 \lstDeleteShortInline@% 647 \begin{tabular}{@{}l @{\hspace{2\parindentlnth}}l@{}}655 \begin{tabular}{@{}l|@{\hspace{\parindentlnth}}l@{}} 648 656 \begin{cfa} 649 657 forall( dtype Unit ) struct scalar { unsigned long value; }; … … 661 669 half_marathon; 662 670 scalar(litres) two_pools = pool + pool; 663 `marathon + pool;` // compilation ERROR671 `marathon + pool;` // ERROR, mismatched types 664 672 \end{cfa} 665 673 \end{tabular} … … 1006 1014 \begin{cfa} 1007 1015 forall( 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}$ 1010 1017 }; 1011 1018 _tuple2(int, int) f() { 1012 1019 _tuple2(double, double) x; 1013 1020 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}$ 1017 1022 }; 1018 1023 _tuple3(int, double, int) y; 1019 1024 } 1020 1025 \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}% 1026 Tuple expressions are then converted directly into compound literals, \eg @[5, 'x', 1.24]@ becomes @(_tuple3(int, char,@ @double)){ 5, 'x', 1.24 }@. 1024 1027 1025 1028 \begin{comment} … … 1105 1108 \begin{cquote} 1106 1109 \lstDeleteShortInline@% 1107 \begin{tabular}{@{}l @{\hspace{2\parindentlnth}}l@{}}1110 \begin{tabular}{@{}l|@{\hspace{2\parindentlnth}}l@{}} 1108 1111 \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{\CFA}} & \multicolumn{1}{c}{\textbf{C}} \\ 1109 1112 \begin{cfa} … … 1174 1177 \centering 1175 1178 \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}} \\ 1178 1181 \begin{cfa} 1179 1182 `choose` ( day ) { 1180 1183 case Mon~Thu: // program 1181 1184 1182 case Fri: // program1185 case Fri: // program 1183 1186 wallet += pay; 1184 1187 `fallthrough;` 1185 case Sat: // party1188 case Sat: // party 1186 1189 wallet -= party; 1187 1190 1188 1191 case Sun: // rest 1189 1192 1190 default: //error1193 default: // print error 1191 1194 } 1192 1195 \end{cfa} … … 1196 1199 case Mon: case Tue: case Wed: case Thu: // program 1197 1200 `break;` 1198 case Fri: // program1201 case Fri: // program 1199 1202 wallet += pay; 1200 1203 1201 case Sat: // party1204 case Sat: // party 1202 1205 wallet -= party; 1203 1206 `break;` 1204 1207 case Sun: // rest 1205 1208 `break;` 1206 default: //error1209 default: // print error 1207 1210 } 1208 1211 \end{cfa} … … 1220 1223 \centering 1221 1224 \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}} \\ 1224 1227 \begin{cfa} 1225 1228 choose ( ... ) { … … 1264 1267 \begin{figure} 1265 1268 \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}} \\ 1268 1271 \begin{cfa} 1269 1272 `LC:` { … … 1349 1352 \subsection{Exception Handling} 1350 1353 1351 The following framework for \CFA exception 1354 The following framework for \CFA exception-handling is in place, excluding some runtime type-information and virtual functions. 1352 1355 \CFA provides two forms of exception handling: \newterm{fix-up} and \newterm{recovery} (see Figure~\ref{f:CFAExceptionHandling})~\cite{Buhr92b,Buhr00a}. 1353 1356 Both 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. … … 1360 1363 \begin{cquote} 1361 1364 \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}} \\ 1364 1367 \begin{cfa} 1365 1368 `exception R { int fix; };` … … 1477 1480 If an exception is raised and caught, the handler is run before the finally clause. 1478 1481 Like 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-trivial lywhen there are multiple types and local accesses.1482 Mimicking the @finally@ clause with mechanisms like RAII is non-trivial when there are multiple types and local accesses. 1480 1483 1481 1484 … … 1530 1533 with ( s, t ) { 1531 1534 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}$ 1536 1539 int c = s.i + t.i; $\C{// unambiguous, qualification}$ 1537 (double)m; $\C{// unambiguous, cast }$1540 (double)m; $\C{// unambiguous, cast s.m}$ 1538 1541 } 1539 1542 \end{cfa} … … 1559 1562 and implicitly opened \emph{after} a function-body open, to give them higher priority: 1560 1563 \begin{cfa} 1561 void ?{}( S & s, int `i` ) with ( s ) ` with( $\emph{\color{red}params}$ )` {1564 void ?{}( S & s, int `i` ) with ( s ) `{` `with( $\emph{\color{red}params}$ )` { 1562 1565 s.i = `i`; j = 3; m = 5.5; 1563 } 1566 } `}` 1564 1567 \end{cfa} 1565 1568 Finally, a cast may be used to disambiguate among overload variables in a @with@ expression: … … 1660 1663 \begin{cfa} 1661 1664 `*` int x, y; 1662 int y;1663 \end{cfa} 1664 & 1665 \begin{cfa} 1666 int `*`x, `*`y ;1665 int z; 1666 \end{cfa} 1667 & 1668 \begin{cfa} 1669 int `*`x, `*`y, z; 1667 1670 1668 1671 \end{cfa} … … 1670 1673 \lstMakeShortInline@% 1671 1674 \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. 1676 The separation of regular and pointer declarations by \CFA declarations enforces greater clarity with only slightly more syntax. 1673 1677 1674 1678 \begin{comment} … … 1792 1796 * [ * int, int ] ( int ) jp; $\C{// pointer to function returning pointer to int and int with int parameter}$ 1793 1797 \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} 1798 Note, the name of the function pointer is specified last, as for other variable declarations. 1798 1799 1799 1800 Finally, new \CFA declarations may appear together with C declarations in the same program block, but cannot be mixed within a specific declaration. … … 1852 1853 This provides a much more orthogonal design for library implementors, obviating the need for workarounds such as @std::reference_wrapper@. 1853 1854 Secondly, \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}1864 1855 Rebinding 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. 1856 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, \eg using a pointer after its storage is deleted.}) and point to different addresses throughout their lifetime, like pointers. 1871 1857 Rebinding is accomplished by extending the existing syntax and semantics of the address-of operator in C. 1872 1858 … … 1880 1866 \begin{itemize} 1881 1867 \item 1882 if @R@ is an rvalue of type {@T &@$_1 \cdots$@ &@$_r$} where $r \ge 1$ references (@&@ symbols) th an @&R@ has type {@T `*`&@$_{\color{red}2} \cdots$@ &@$_{\color{red}r}$}, \\ \ie @T@ pointer with $r-1$ references (@&@ symbols).1868 if @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). 1883 1869 1884 1870 \item … … 1914 1900 \end{cfa} 1915 1901 This 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. 1917 1903 1918 1904 … … 1928 1914 \begin{tabular}{@{}l@{\hspace{3em}}l|l@{}} 1929 1915 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C Type Nesting}} & \multicolumn{1}{c|}{\textbf{C Implicit Hoisting}} & \multicolumn{1}{c}{\textbf{\CFA}} \\ 1930 \hline1931 1916 \begin{cfa} 1932 1917 struct S { … … 2259 2244 W w, heavy = { 20 }; 2260 2245 w = 155|_lb|; 2261 w = 0b1111|_lb|; // error,binary unsupported2246 // binary unsupported 2262 2247 w = 0${\color{red}\LstBasicStyle{'}}$233|_lb|; // quote separator 2263 2248 w = 0x9b|_kg|; … … 2307 2292 \begin{cquote} 2308 2293 \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}} \\ 2311 2296 \begin{cfa} 2312 2297 MIN 2313 2314 2298 MAX 2315 2316 2299 PI 2317 2300 E … … 2319 2302 & 2320 2303 \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 2304 CHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, LLONG_MIN, FLT_MIN, DBL_MIN, LDBL_MIN 2305 UCHAR_MAX, SHRT_MAX, INT_MAX, LONG_MAX, LLONG_MAX, FLT_MAX, DBL_MAX, LDBL_MAX 2325 2306 M_PI, M_PIl 2326 2307 M_E, M_El … … 2441 2422 2442 2423 \begin{table} 2424 \caption{Storage-Management Operations} 2425 \label{t:StorageManagementOperations} 2443 2426 \centering 2444 2427 \lstDeleteShortInline@% … … 2460 2443 \lstDeleteShortInline~% 2461 2444 \lstMakeShortInline@% 2462 \caption{Storage-Management Operations}2463 \label{t:StorageManagementOperations}2464 2445 \end{table} 2465 2446 … … 2589 2570 \end{cquote} 2590 2571 There 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} 2592 2573 The implicit separator character (space/blank) is a separator not a terminator. 2593 2574 The rules for implicitly adding the separator are: … … 2608 2589 }% 2609 2590 \end{itemize} 2591 \end{comment} 2610 2592 There are functions to set and get the separator string, and manipulators to toggle separation on and off in the middle of output. 2611 2593 … … 2656 2638 2657 2639 2658 \section{ Evaluation}2640 \section{Polymorphic Evaluation} 2659 2641 \label{sec:eval} 2660 2642 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. 2644 A runtime evaluation is performed to compare the cost of alternative styles of polymorphism. 2645 The 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. 2648 The experiment is a set of generic-stack micro-benchmarks~\cite{CFAStackEvaluation} in C, \CFA, and \CC (see implementations in Appendix~\ref{sec:BenchmarkStackImplementations}). 2664 2649 Since 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. 2665 2650 A more illustrative comparison measures the costs of idiomatic usage of each language's features. … … 2692 2677 \end{figure} 2693 2678 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.2679 The 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. 2695 2680 The \CCV variant illustrates an alternative object-oriented idiom where all objects inherit from a base @object@ class, mimicking a Java-like interface; 2696 2681 hence runtime checks are necessary to safely down-cast objects. 2697 2682 The 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.2683 Note, the C benchmark uses unchecked casts as C has no runtime mechanism to perform such checks, while \CFA and \CC provide type-safety statically. 2699 2684 2700 2685 Figure~\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. … … 2711 2696 2712 2697 \begin{table} 2713 \centering2714 2698 \caption{Properties of benchmark code} 2715 2699 \label{tab:eval} 2700 \centering 2716 2701 \newcommand{\CT}[1]{\multicolumn{1}{c}{#1}} 2717 2702 \begin{tabular}{rrrrr} … … 2726 2711 The 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; 2727 2712 this 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.2713 By 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. 2729 2714 \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. 2715 The outlier for \CFA, pop @pair@, results from the complexity of the generated-C polymorphic code. 2716 The gcc compiler is unable to optimize some dead code and condense nested calls; 2717 a compiler designed for \CFA could easily perform these optimizations. 2732 2718 Finally, the binary size for \CFA is larger because of static linking with the \CFA libraries. 2733 2719 … … 2746 2732 The \CFA benchmark is able to eliminate all redundant type annotations through use of the polymorphic @alloc@ function discussed in Section~\ref{sec:libraries}. 2747 2733 2734 We conjecture these results scale across most generic data-types as the underlying polymorphic implement is constant. 2735 2748 2736 2749 2737 \section{Related Work} … … 2751 2739 2752 2740 \subsection{Polymorphism} 2741 2742 ML~\cite{ML} was the first language to support parametric polymorphism. 2743 Like \CFA, it supports universal type parameters, but not the use of assertions and traits to constrain type arguments. 2744 Haskell~\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. 2745 Unlike \CFA, Haskell requires an explicit association between types and their classes that specifies the implementation of operations. 2746 These 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. 2747 Haskell 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. 2753 2748 2754 2749 \CC provides three disjoint polymorphic extensions to C: overloading, inheritance, and templates. … … 2804 2799 Go does not have tuples but supports MRVF. 2805 2800 Java'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.2801 Tuples 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. 2807 2802 2808 2803 … … 2835 2830 Finally, we demonstrate that \CFA performance for some idiomatic cases is better than C and close to \CC, showing the design is practically applicable. 2836 2831 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. 2832 While 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. 2833 There is also new work on a number of \CFA features, including arrays with size, runtime type-information, virtual functions, user-defined conversions, and modules. 2834 While \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. 2835 Hence it may be beneficial to provide a mechanism for performance-sensitive code. 2843 2836 Two 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). 2844 2837 These approaches are not mutually exclusive and allow performance optimizations to be applied only when necessary, without suffering global code-bloat. … … 2849 2842 2850 2843 The 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 2844 Funding 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% 2854 2848 \bibliography{pl} 2855 2849 }% 2856 2850 2857 2851 \appendix -
doc/papers/general/evaluation/timing.gp
r14a61b5 r5fec3f6 25 25 26 26 set label "23.9" at 7.125,10.5 27 27 set style fill pattern 4 border lt -1 28 28 # set datafile separator "," 29 29 plot for [COL=2:5] 'evaluation/timing.dat' using (column(COL)/SCALE):xticlabels(1) title columnheader -
src/main.cc
r14a61b5 r5fec3f6 10 10 // Created On : Fri May 15 23:12:02 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun May 6 22:25:59201813 // Update Count : 49 112 // Last Modified On : Mon May 7 14:35:57 2018 13 // Update Count : 492 14 14 // 15 15 … … 407 407 opterr = 0; // (global) prevent getopt from printing error messages 408 408 409 bool W error = false;409 bool Wsuppress = false, Werror = false; 410 410 int c; 411 411 while ( (c = getopt_long( argc, argv, "abBcCdefgGlLmnNpqrstTvwW:yzZD:F:", long_opts, &long_index )) != -1 ) { … … 495 495 break; 496 496 case 'w': 497 SemanticWarning_SuppressAll();497 Wsuppress = true; 498 498 break; 499 499 case 'W': … … 545 545 SemanticWarning_WarningAsError(); 546 546 } // if 547 if ( Wsuppress ) { 548 SemanticWarning_SuppressAll(); 549 } // if 547 550 // for ( const auto w : WarningFormats ) { 548 551 // cout << w.name << ' ' << (int)w.severity << endl;
Note: See TracChangeset
for help on using the changeset viewer.