- Timestamp:
- May 23, 2018, 8:59:45 AM (6 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:
- 6f9bc09, b9da9585
- Parents:
- 2c88368
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/papers/general/Paper.tex
r2c88368 r59c034c6 243 243 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. 244 244 245 \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.245 \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 source and runtime compatibility in the familiar C programming model. 246 246 The four key design goals for \CFA~\cite{Bilson03} are: 247 247 (1) The behaviour of standard C code must remain the same when translated by a \CFA compiler as when translated by a C compiler; … … 273 273 Starting with a translator versus a compiler makes it easier and faster to generate and debug C object-code rather than intermediate, assembler or machine code. 274 274 The translator design is based on the \emph{visitor pattern}, allowing multiple passes over the abstract code-tree, which works well for incrementally adding new feature through additional visitor passes. 275 At the heart of the translator is the type resolver, which handles the polymorphic routine/type overload-resolution.275 At the heart of the translator is the type resolver, which handles the polymorphic function/type overload-resolution. 276 276 % @plg2[8]% cd cfa-cc/src; cloc libcfa 277 277 % ------------------------------------------------------------------------------- … … 310 310 311 311 Finally, it is impossible to describe a programming language without usages before definitions. 312 Therefore, syntax and semantics appear before explanations ;313 hence, patience is necessary until details are presented.312 Therefore, syntax and semantics appear before explanations, and related work (Section~\ref{s:RelatedWork}) is deferred until \CFA is presented; 313 hence, patience is necessary until details are discussed. 314 314 315 315 … … 329 329 \end{quote} 330 330 \vspace{-9pt} 331 C already has a limited form of ad-hoc polymorphism in the form ofits basic arithmetic operators, which apply to a variety of different types using identical syntax.331 C already has a limited form of ad-hoc polymorphism in its basic arithmetic operators, which apply to a variety of different types using identical syntax. 332 332 \CFA extends the built-in operator overloading by allowing users to define overloads for any function, not just operators, and even any variable; 333 333 Section~\ref{sec:libraries} includes a number of examples of how this overloading simplifies \CFA programming relative to C. … … 1535 1535 The difference between parallel and nesting occurs for fields with the same name and type: 1536 1536 \begin{cfa} 1537 struct S { int `i`; int j; double m; } s, w; 1537 struct S { int `i`; int j; double m; } s, w; $\C{// field i has same type in structure types S and T}$ 1538 1538 struct T { int `i`; int k; int m; } t, w; 1539 with ( s, t ) { 1539 with ( s, t ) { $\C{// open structure variables s and t in parallel}$ 1540 1540 j + k; $\C{// unambiguous, s.j + t.k}$ 1541 1541 m = 5.0; $\C{// unambiguous, s.m = 5.0}$ … … 2005 2005 Destruction parameters are useful for specifying storage-management actions, such as de-initialize but not deallocate.}. 2006 2006 \begin{cfa} 2007 struct VLA { int len, * data; }; $\C{// variable length array of integers}$2008 void ?{}( VLA & vla ) with ( vla ) { len = 10; data = alloc( len); } $\C{// default constructor}$2007 struct VLA { int size, * data; }; $\C{// variable length array of integers}$ 2008 void ?{}( VLA & vla ) with ( vla ) { size = 10; data = alloc( size ); } $\C{// default constructor}$ 2009 2009 void ^?{}( VLA & vla ) with ( vla ) { free( data ); } $\C{// destructor}$ 2010 2010 { … … 2019 2019 \CFA also provides syntax for \newterm{initialization} and \newterm{copy}: 2020 2020 \begin{cfa} 2021 void ?{}( VLA & vla, int size, char fill ) with ( vla) { $\C{// initialization}$2022 len = size; data = alloc( len, fill );2021 void ?{}( VLA & vla, int size, char fill = '\0' ) { $\C{// initialization}$ 2022 vla.[ size, data ] = [ size, alloc( size, fill ) ]; 2023 2023 } 2024 2024 void ?{}( VLA & vla, VLA other ) { $\C{// copy, shallow}$ 2025 vla .len = other.len; vla.data = other.data;2025 vla = other; 2026 2026 } 2027 2027 \end{cfa} … … 2048 2048 y{ x }; $\C{// reallocate y, points to x}$ 2049 2049 x{}; $\C{// reallocate x, not pointing to y}$ 2050 // ^z{}; ^y{}; ^x{}; 2051 } 2050 } // ^z{}; ^y{}; ^x{}; 2052 2051 \end{cfa} 2053 2052 … … 2740 2739 2741 2740 \section{Related Work} 2741 \label{s:RelatedWork} 2742 2742 2743 2743
Note: See TracChangeset
for help on using the changeset viewer.