Ignore:
Timestamp:
Apr 23, 2018, 12:57:46 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
57acae0
Parents:
ba89e9b7 (diff), c8ad5d9 (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' into references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/papers/general/Paper.tex

    rba89e9b7 rda7fe39  
    1818\usepackage{upquote}                                            % switch curled `'" to straight
    1919\usepackage{listings}                                           % format program code
     20\captionsetup{justification=raggedright,singlelinecheck=false}
    2021%\usepackage{enumitem}
    2122%\setlist[itemize]{topsep=3pt,itemsep=2pt,parsep=0pt}% global
     
    2829\renewcommand{\linenumberfont}{\scriptsize\sffamily}
    2930
    30 \lefthyphenmin=4                                                        % hyphen only after 4 characters
    31 \righthyphenmin=4
     31\lefthyphenmin=3                                                        % hyphen only after 4 characters
     32\righthyphenmin=3
    3233
    3334%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     
    8687% Latin abbreviation
    8788\newcommand{\abbrevFont}{\textit}                       % set empty for no italics
    88 \newcommand{\EG}{\abbrevFont{e}.\abbrevFont{g}.}
     89\@ifundefined{eg}{
     90\newcommand{\EG}{\abbrevFont{e}\abbrevFont{g}}
    8991\newcommand*{\eg}{%
    9092        \@ifnextchar{,}{\EG}%
    9193                {\@ifnextchar{:}{\EG}%
    9294                        {\EG,\xspace}}%
    93 }%
    94 \newcommand{\IE}{\abbrevFont{i}.\abbrevFont{e}.}
     95}}{}%
     96\@ifundefined{ie}{
     97\newcommand{\IE}{\abbrevFont{i}\abbrevFont{e}}
    9598\newcommand*{\ie}{%
    9699        \@ifnextchar{,}{\IE}%
    97100                {\@ifnextchar{:}{\IE}%
    98101                        {\IE,\xspace}}%
    99 }%
     102}}{}%
     103\@ifundefined{etc}{
    100104\newcommand{\ETC}{\abbrevFont{etc}}
    101105\newcommand*{\etc}{%
    102106        \@ifnextchar{.}{\ETC}%
    103107        {\ETC.\xspace}%
    104 }%
     108}}{}%
     109\@ifundefined{etal}{
    105110\newcommand{\ETAL}{\abbrevFont{et}~\abbrevFont{al}}
    106 \renewcommand*{\etal}{%
     111\newcommand*{\etal}{%
    107112        \@ifnextchar{.}{\protect\ETAL}%
    108113                {\protect\ETAL.\xspace}%
    109 }%
     114}}{}%
     115\@ifundefined{viz}{
    110116\newcommand{\VIZ}{\abbrevFont{viz}}
    111117\newcommand*{\viz}{%
    112118        \@ifnextchar{.}{\VIZ}%
    113119                {\VIZ.\xspace}%
    114 }%
     120}}{}%
    115121\makeatother
    116122
     
    125131\lstdefinelanguage{CFA}[ANSI]{C}{
    126132        morekeywords={
    127                 _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, _At, __attribute,
    128                 __attribute__, auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__,
    129                 __const, __const__, disable, dtype, enable, exception, __extension__, fallthrough, fallthru,
    130                 finally, forall, ftype, _Generic, _Imaginary, inline, __label__, lvalue, _Noreturn, one_t,
    131                 otype, restrict, _Static_assert, throw, throwResume, trait, try, ttype, typeof, __typeof,
    132                 __typeof__, virtual, with, zero_t},
    133         morekeywords=[2]{
    134                 _Atomic, coroutine, is_coroutine, is_monitor, is_thread, monitor, mutex, nomutex, or,
    135                 resume, suspend, thread, _Thread_local, waitfor, when, yield},
     133                _Alignas, _Alignof, __alignof, __alignof__, asm, __asm, __asm__, __attribute, __attribute__,
     134                auto, _Bool, catch, catchResume, choose, _Complex, __complex, __complex__, __const, __const__,
     135                coroutine, disable, dtype, enable, exception, __extension__, fallthrough, fallthru, finally,
     136                __float80, float80, __float128, float128, forall, ftype, _Generic, _Imaginary, __imag, __imag__,
     137                inline, __inline, __inline__, __int128, int128, __label__, monitor, mutex, _Noreturn, one_t, or,
     138                otype, restrict, __restrict, __restrict__, __signed, __signed__, _Static_assert, thread,
     139                _Thread_local, throw, throwResume, timeout, trait, try, ttype, typeof, __typeof, __typeof__,
     140                virtual, __volatile, __volatile__, waitfor, when, with, zero_t},
    136141        moredirectives={defined,include_next}%
    137142}
     
    154159literate={-}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.1ex}}}}1 {^}{\raisebox{0.6ex}{$\scriptstyle\land\,$}}1
    155160        {~}{\raisebox{0.3ex}{$\scriptstyle\sim\,$}}1 % {`}{\ttfamily\upshape\hspace*{-0.1ex}`}1
    156         {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.5ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex{\textgreater}}2,
     161        {<-}{$\leftarrow$}2 {=>}{$\Rightarrow$}2 {->}{\makebox[1ex][c]{\raisebox{0.4ex}{\rule{0.8ex}{0.075ex}}}\kern-0.2ex{\textgreater}}2,
    157162moredelim=**[is][\color{red}]{`}{`},
    158163}% lstset
     
    174179\author[1]{Robert Schluntz}
    175180\author[1]{Peter A. Buhr*}
    176 \authormark{Aaron Moss \textsc{et al}}
    177 
    178 \address[1]{\orgdiv{David R. Cheriton School of Computer Science}, \orgname{University of Waterloo}, \orgaddress{\state{Ontario}, \country{Canada}}}
    179 
    180 \corres{*Peter A. Buhr, \email{pabuhr{\char`\@}uwaterloo.ca}}
    181 \presentaddress{David R. Cheriton School of Computer Science, University of Waterloo, Waterloo, ON, N2L 3G1, Canada}
    182 
     181\authormark{MOSS \textsc{et al}}
     182
     183\address[1]{\orgdiv{Cheriton School of Computer Science}, \orgname{University of Waterloo}, \orgaddress{\state{Waterloo, ON}, \country{Canada}}}
     184
     185\corres{*Peter A. Buhr, Cheriton School of Computer Science, University of Waterloo, 200 University Avenue West, Waterloo, ON, N2L 3G1, Canada. \email{pabuhr{\char`\@}uwaterloo.ca}}
     186
     187\fundingInfo{Natural Sciences and Engineering Research Council of Canada}
    183188
    184189\abstract[Summary]{
     
    224229Nevertheless, C, first standardized over thirty years ago, lacks many features that make programming in more modern languages safer and more productive.
    225230
    226 \CFA (pronounced ``C-for-all'', and written \CFA or Cforall) is an evolutionary extension of the C programming language that aims to add modern language features to C while maintaining both source compatibility with C and a familiar programming model for programmers.
     231\CFA (pronounced ``C-for-all'', and written \CFA or Cforall) is an evolutionary extension of the C programming language that aims to add modern language features to C, while maintaining both source and runtime compatibility with C and a familiar programming model for programmers.
    227232The four key design goals for \CFA~\cite{Bilson03} are:
    228233(1) The behaviour of standard C code must remain the same when translated by a \CFA compiler as when translated by a C compiler;
     
    324329A simple example is leveraging the existing type-unsafe (@void *@) C @bsearch@ to binary search a sorted float array:
    325330\begin{cfa}
    326 void * bsearch( const void * key, const void * base, size_t nmemb, size_t size,
    327                                          int (* compar)( const void *, const void * ));
     331void * bsearch( const void * key, const void * base, size_t nmemb, size_t size, int (* compar)( const void *, const void * ));
    328332int comp( const void * t1, const void * t2 ) {
    329333         return *(double *)t1 < *(double *)t2 ? -1 : *(double *)t2 < *(double *)t1 ? 1 : 0;
     
    332336double * val = (double *)bsearch( &key, vals, 10, sizeof(vals[0]), comp ); $\C{// search sorted array}$
    333337\end{cfa}
    334 which can be augmented simply with a generalized, type-safe, \CFA-overloaded wrappers:
     338which can be augmented simply with generalized, type-safe, \CFA-overloaded wrappers:
    335339\begin{cfa}
    336340forall( otype T | { int ?<?( T, T ); } ) T * bsearch( T key, const T * arr, size_t size ) {
     
    394398        T ?++( T * );
    395399};
    396 forall( otype T `| summable( T )` ) T sum( T a[$\,$], size_t size ) {  // use trait
     400forall( otype T `| summable( T )` ) T sum( T a[$\,$], size_t size ) {$\C{// use trait}$
    397401        `T` total = { `0` };                                    $\C{// instantiate T from 0 by calling its constructor}$
    398402        for ( unsigned int i = 0; i < size; i += 1 ) total `+=` a[i]; $\C{// select appropriate +}$
     
    572576        return (scalar(U)){ a.value + b.value };
    573577}
    574 scalar(metres) half_marathon = { 21093 };
    575 scalar(litres) swimming_pool = { 2500000 };
     578scalar(metres) half_marathon = { 21_093 };
     579scalar(litres) swimming_pool = { 2_500_000 };
    576580scalar(metres) marathon = half_marathon + half_marathon;
    577581scalar(litres) two_pools = swimming_pool + swimming_pool;
     
    720724\end{cfa}
    721725Here, the mass assignment sets all members of @s@ to zero.
    722 Since tuple-index expressions are a form of member-access expression, it is possible to use tuple-index expressions in conjunction with member tuple expressions to manually restructure a tuple (\eg rearrange, drop, and duplicate components).
     726Since tuple-index expressions are a form of member-access expression, it is possible to use tuple-index expressions in conjunction with member-tuple expressions to manually restructure a tuple (\eg rearrange, drop, and duplicate components).
    723727\begin{cfa}
    724728[int, int, long, double] x;
     
    18751879\lstDeleteShortInline@%
    18761880\begin{tabular}{@{}l@{\hspace{3em}}l|l@{}}
    1877 \multicolumn{1}{c@{\hspace{3em}}}{\textbf{C Type Nesting}}      & \multicolumn{1}{c}{\textbf{C Implicit Hoisting}}      & \multicolumn{1}{|c}{\textbf{\CFA}}    \\
     1881\multicolumn{1}{c@{\hspace{3em}}}{\textbf{C Type Nesting}}      & \multicolumn{1}{c|}{\textbf{C Implicit Hoisting}}     & \multicolumn{1}{c}{\textbf{\CFA}}     \\
    18781882\hline
    18791883\begin{cfa}
     
    19982002{
    19992003        VLA  x,            y = { 20, 0x01 },     z = y; $\C{// z points to y}$
    2000         //    ?{}( x );   ?{}( y, 20, 0x01 );    ?{}( z, y );
     2004        //      ?{}( x );   ?{}( y, 20, 0x01 );   ?{}( z, y );
    20012005        ^x{};                                                                   $\C{// deallocate x}$
    20022006        x{};                                                                    $\C{// reallocate x}$
     
    20232027These semantics closely mirror the rule for implicit declaration of constructors in \CC\cite[p.~186]{ANSI98:C++}.
    20242028
    2025 In some circumstance programmers may not wish to have constructor and destructor calls.
    2026 In these cases, \CFA provides the initialization syntax \lstinline|S x @= {}|, and the object becomes unmanaged, so implicit constructor and destructor calls are not generated.
    2027 Any C initializer can be the right-hand side of an \lstinline|@=| initializer, \eg \lstinline|VLA a @= { 0, 0x0 }|, with the usual C initialization semantics.
     2029In some circumstance programmers may not wish to have implicit constructor and destructor generation and calls.
     2030In these cases, \CFA provides the initialization syntax \lstinline|S x `@=` {}|, and the object becomes unmanaged, so implicit constructor and destructor calls are not generated.
     2031Any C initializer can be the right-hand side of an \lstinline|@=| initializer, \eg \lstinline|VLA a @= { 0, 0x0 }|, with the usual C initialization semantics.
     2032The same syntax can be used in a compound literal, \eg \lstinline|a = VLA`@`{ 0, 0x0 }|, to create a C-style literal.
    20282033The point of \lstinline|@=| is to provide a migration path from legacy C code to \CFA, by providing a mechanism to incrementally convert to implicit initialization.
    20292034
     
    20432048\subsection{Integral Suffixes}
    20442049
    2045 Additional integral suffixes are added to cover all the integral types and lengths.
     2050New integral suffixes @hh@ (half of half of @int@) for @char@, @h@ (half of @int@) for @short@, and @z@ for @size_t@, and length suffixes for 8, 16, 32, 64, and 128 bit integers.
     2051%Additional integral suffixes are added to cover all the integral types and lengths.
    20462052\begin{cquote}
    20472053\lstDeleteShortInline@%
     
    20492055\begin{cfa}
    2050205620_`hh`     // signed char
    2051 21_`hhu`   // unsigned char
     205721_`hh`u   // unsigned char
    2052205822_`h`       // signed short int
    2053 23_`uh`     // unsigned short int
    2054 24_`z`       // size_t
     205923_u`h`     // unsigned short int
     206024`z`         // size_t
    20552061\end{cfa}
    20562062&
    20572063\begin{cfa}
    2058206420_`L8`      // int8_t
    2059 21_`ul8`     // uint8_t
     206521_u`l8`     // uint8_t
    2060206622_`l16`     // int16_t
    2061 23_`ul16`   // uint16_t
     206723_u`l16`   // uint16_t
    2062206824_`l32`     // int32_t
    20632069\end{cfa}
    20642070&
    20652071\begin{cfa}
    2066 25_`ul32`      // uint32_t
     207225_u`l32`      // uint32_t
    2067207326_`l64`        // int64_t
    2068 27_`l64u`      // uint64_t
     207427_`l64`u      // uint64_t
    2069207526_`L128`     // int128
    2070 27_`L128u`   // unsigned int128
     207627_`L128`u   // unsigned int128
    20712077\end{cfa}
    20722078\end{tabular}
     
    20832089To provide this precision, \CFA introduces a new type @zero_t@ as the type of literal @0@ (somewhat analagous to @nullptr_t@ and @nullptr@ in \CCeleven);
    20842090@zero_t@ can only take the value @0@, but has implicit conversions to the integer and pointer types so that C code involving @0@ continues to work.
    2085 With this addition, \CFA rewrites @if (x)@ and similar expressions to @if ((x) != 0)@ or the appropriate analogue, and any type @T@ is ``truthy'' by defining an operator overload @int ?!=?(T, zero_t)@.
     2091With this addition, \CFA rewrites @if (x)@ and similar expressions to @if ( (x) != 0 )@ or the appropriate analogue, and any type @T@ is ``truthy'' by defining an operator overload @int ?!=?( T, zero_t )@.
    20862092\CC makes types truthy by adding a conversion to @bool@;
    20872093prior to the addition of explicit cast operators in \CCeleven, this approach had the pitfall of making truthy types transitively convertable to any numeric type;
     
    21152121\multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{postfix function}}        & \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{constant}}      & \multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{variable/expression}}   & \multicolumn{1}{c}{\textbf{postfix pointer}}  \\
    21162122\begin{cfa}
    2117 int ?`h( int s );
    2118 int ?`h( double s );
    2119 int ?`m( char c );
    2120 int ?`m( const char * s );
    2121 int ?`t( int a, int b, int c );
    2122 \end{cfa}
    2123 &
    2124 \begin{cfa}
    2125 0 `h;
    2126 3.5`h;
    2127 '1'`m;
    2128 "123" "456"`m;
    2129 [1,2,3]`t;
     2123int |?`h|( int s );
     2124int |?`h|( double s );
     2125int |?`m|( char c );
     2126int |?`m|( const char * s );
     2127int |?`t|( int a, int b, int c );
     2128\end{cfa}
     2129&
     2130\begin{cfa}
     21310 |`h|;
     21323.5|`h|;
     2133'1'|`m|;
     2134"123" "456"|`m|;
     2135[1,2,3]|`t|;
    21302136\end{cfa}
    21312137&
    21322138\begin{cfa}
    21332139int i = 7;
    2134 i`h;
    2135 (i + 3)`h;
    2136 (i + 3.5)`h;
    2137 
    2138 \end{cfa}
    2139 &
    2140 \begin{cfa}
    2141 int (* ?`p)( int i );
    2142 ?`p = ?`h;
    2143 3`p;
    2144 i`p;
    2145 (i + 3)`p;
     2140i|`h|;
     2141(i + 3)|`h|;
     2142(i + 3.5)|`h|;
     2143
     2144\end{cfa}
     2145&
     2146\begin{cfa}
     2147int (* |?`p|)( int i );
     2148|?`p| = |?`h|;
     21493|`p|;
     2150i|`p|;
     2151(i + 3)|`p|;
    21462152\end{cfa}
    21472153\end{tabular}
     
    21582164\lstset{language=CFA,moredelim=**[is][\color{red}]{|}{|},deletedelim=**[is][]{`}{`}}
    21592165\lstDeleteShortInline@%
    2160 \begin{tabular}{@{}l@{\hspace{\parindentlnth}}l@{}}
    2161 \multicolumn{1}{c@{\hspace{\parindentlnth}}}{\textbf{\CFA}}     & \multicolumn{1}{c}{\textbf{\CC}}      \\
     2166\begin{tabular}{@{}l@{\hspace{2\parindentlnth}}l@{}}
     2167\multicolumn{1}{c@{\hspace{2\parindentlnth}}}{\textbf{\CFA}}    & \multicolumn{1}{c}{\textbf{\CC}}      \\
    21622168\begin{cfa}
    21632169struct W {
     
    22552261\begin{cfa}
    22562262MIN
    2257 
    22582263MAX
    2259 
    22602264PI
    22612265E
     
    22632267&
    22642268\begin{cfa}
    2265 SCHAR_MIN, CHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, LLONG_MIN,
    2266                 FLT_MIN, DBL_MIN, LDBL_MIN
    2267 SCHAR_MAX, UCHAR_MAX, SHRT_MAX, INT_MAX, LONG_MAX, LLONG_MAX,
    2268                 FLT_MAX, DBL_MAX, LDBL_MAX
     2269SCHAR_MIN, CHAR_MIN, SHRT_MIN, INT_MIN, LONG_MIN, LLONG_MIN, FLT_MIN, DBL_MIN, LDBL_MIN
     2270SCHAR_MAX, UCHAR_MAX, SHRT_MAX, INT_MAX, LONG_MAX, LLONG_MAX, FLT_MAX, DBL_MAX, LDBL_MAX
    22692271M_PI, M_PIl
    22702272M_E, M_El
     
    24392441ip = (int *)malloc( sizeof( int ) ); memset( ip, fill, dim * sizeof( int ) );
    24402442ip = (int *)realloc( ip, 2 * dim * sizeof( int ) );
    2441 ip = (int *)realloc( ip, 4 * dim * sizeof( int ) );
    2442                         memset( ip, fill, 4 * dim * sizeof( int ) );
     2443ip = (int *)realloc( ip, 4 * dim * sizeof( int ) ); memset( ip, fill, 4 * dim * sizeof( int ) );
     2444
    24432445ip = memalign( 16, sizeof( int ) );
    24442446ip = memalign( 16, sizeof( int ) ); memset( ip, fill, sizeof( int ) );
Note: See TracChangeset for help on using the changeset viewer.