# Changeset e84382b for doc/papers/general/Paper.tex

Ignore:
Timestamp:
Mar 9, 2018, 1:34:04 PM (4 years ago)
Branches:
aaron-thesis, arm-eh, 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, resolv-new, with_gc
Children:
860f19f
Parents:
b51e5fdb (diff), 3d8f2f8 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

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

File:
1 edited

### Legend:

Unmodified
 rb51e5fdb Hence, programmers can easily form local environments, adding and modifying appropriate functions, to maximize reuse of other existing functions and types. Unconstruction is a mechanism to distribute @forall@ over related routines/types (see @stack@ examples in Section~\ref{sec:eval}): \begin{cfa} forall( otype T ) {                                                     $\C{// forall block}$ struct stack { stack_node(T) * head; }; $\C{// generic type}$ void push( stack(T) & s, T value ) ...  $\C{// generic operations}$ T pop( stack(T) & s ) ... } \end{cfa} Each block declaration is prefixed with the initial @forall@ clause significantly reducing duplication. \subsection{Traits} % \end{cfa} % so the thunk provides flattening and structuring conversions to inferred functions, improving the compatibility of tuples and polymorphism. % These thunks are generated locally using gcc nested-functions, rather hositing them to the external scope, so they can easily access local state. % These thunks are generated locally using gcc nested-functions, rather hoisting them to the external scope, so they can easily access local state. \lstMakeShortInline@% \end{cquote} The target label must be below the @fallthrough@, \ie @fallthrough@ cannot form a loop, and the label may not be nested in a control structor, \ie it must be at the same level as the @case@ clauses; The target label must be below the @fallthrough@, \ie @fallthrough@ cannot form a loop, and the label may not be nested in a control structure, \ie it must be at the same level as the @case@ clauses; the target label may be case @default@. \begin{cfa} struct W { double stones; W() { stones = 0.0; } W( double w ) { stones = w; } double stones; W() { stones = 0.0; } W( double w ) { stones = w; } }; W operator+( W l, W r ) { \CC is the best known C-based language, and is similar to \CFA in that both are extensions to C with source and runtime backwards compatibility. Specific difference between \CFA and \CC have been identified in prior sections, with a final observation that \CFA has equal or few tokens to express the same notion in several cases. The key difference between design philosophies is that \CFA is easier for C programmers to understand, by maintaining a procedural paradigm and avoiding complex interactions among extensions. Specific difference between \CFA and \CC have been identified in prior sections, with a final observation that \CFA has equal or fewer tokens to express the same notion in many cases. The key difference in design philosophies is that \CFA is easier for C programmers to understand by maintaining a procedural paradigm and avoiding complex interactions among extensions. \CC, on the other hand, has multiple overlapping features (such as the three forms of polymorphism), many of which have complex interactions with its object-oriented design. As a result, \CC has a steep learning curve for even experienced C programmers, especially when attempting to maintain performance equivalent to C legacy code. As a result, \CC has a steep learning curve for even experienced C programmers, especially when attempting to maintain performance equivalent to C legacy-code. There are several other C extension-languages with less usage and even more dramatic changes than \CC. Other languages extend C with more focused features. CUDA~\cite{Nickolls08}, ispc~\cite{Pharr12}, and Sierra~\cite{Leissa14} add data-parallel primitives to C or \CC; such features have not yet been added to \CFA, but are not precluded by the design. Finaly, some C extensions (or suggested extensions) attempt to provide a more memory-safe C~\cite{Boehm88}; type-checked polymorphism in \CFA covers several of C's memory-safety holes, but more aggressive approaches such as annotating all pointer types with their nullability are contradictory to \CFA's backwards compatibility goals. such features have not yet been added to \CFA, but are easily incorporated within its design. Finally, some C extensions (or suggested extensions) attempt to provide a more memory-safe C~\cite{Boehm88,Rafkind09}; type-checked polymorphism in \CFA covers several of C's memory-safety issues, but more aggressive approaches such as annotating all pointer types with their nullability are contradictory to \CFA's backwards compatibility goals. struct stack_node * n = s->head; s->head = n->next; void * x = n->value; void * v = n->value; free( n ); return x; return v; } \end{cfa} \end{cfa} \begin{comment} forall( otype T ) { struct stack_node { T value; stack_node(T) * next; }; struct stack { stack_node(T) * head; }; void clear( stack(T) & s ) with( s ) { for ( stack_node(T) * next = head; next; ) { stack_node(T) * crnt = next; next = crnt->next; ^(*crnt){}; free(crnt); } head = 0; } void ?{}( stack(T) & s ) { (s.head){ 0 }; } void ?{}( stack(T) & s, stack(T) t ) { stack_node(T) ** crnt = &s.head; for ( stack_node(T) * next = t.head; next; next = next->next ) { *crnt = alloc(); ((*crnt)->value){ next->value }; crnt = &(*crnt)->next; } *crnt = 0; } stack(T) ?=?( stack(T) & s, stack(T) t ) { if ( s.head == t.head ) return s; clear( s ); s{ t }; return s; } void ^?{}( stack(T) & s) { clear( s ); } _Bool empty( const stack(T) & s ) { return s.head == 0; } void push( stack(T) & s, T value ) with( s ) { stack_node(T) * n = alloc(); (*n){ value, head }; head = n; } T pop( stack(T) & s ) with( s ) { stack_node(T) * n = head; head = n->next; T v = n->value; ^(*n){}; free( n ); return v; } } \end{comment} \medskip\noindent \CC }; node * head; stack() : head( nullptr ) {} stack( const stack & o) { copy( o ); } stack( stack && o ) : head( o.head ) { o.head = nullptr; } void clear() { for ( node * next = head; next; ) { *crnt = nullptr; } stack() : head( nullptr) {} stack( const stack & o ) { copy( o ); } ~stack() { clear(); } stack & operator= ( const stack & o) { stack & operator= ( const stack & o ) { if ( this == &o ) return *this; clear(); node * n = head; head = n->next; T x = std::move( n->value ); T v = std::move( n->value ); delete n; return x; return v; } }; struct node { ptr