Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/proposals/concurrency/text/cforall.tex

    r6090518 rcae28da  
    5252% ======================================================================
    5353\section{Operators}
    54 Overloading also extends to operators. The syntax for denoting operator-overloading is to name a routine with the symbol of the operator and question marks where the arguments of the operation occur, e.g.:
     54Overloading also extends to operators. The syntax for denoting operator-overloading is to name a routine with the symbol of the operator and question marks where the arguments of the operation appear, e.g.:
    5555\begin{cfacode}
    5656int ++? (int op);                       //unary prefix increment
     
    7272% ======================================================================
    7373\section{Constructors/Destructors}
    74 Object lifetime is often a challenge in concurrency. \CFA uses the approach of giving concurrent meaning to object lifetime as a means of synchronization and/or mutual exclusion. Since \CFA relies heavily on the lifetime of objects, constructors and destructors is a core feature required for concurrency and parallelism. \CFA uses the following syntax for constructors and destructors :
     74Object lifetime is often a challenge in concurrency. \CFA uses the approach of giving concurrent meaning to object lifetime as a means of synchronization and/or mutual exclusion. Since \CFA relies heavily on the lifetime of objects, constructors and destructors is a core feature required for concurrency and parallelism. \CFA uses the following syntax for constructors and destructors:
    7575\begin{cfacode}
    7676struct S {
     
    107107% ======================================================================
    108108\section{Parametric Polymorphism}
    109 Routines in \CFA can also be reused for multiple types. This capability is done using the \code{forall} clause, which gives \CFA its name. \code{forall} clauses allow separately compiled routines to support generic usage over multiple types. For example, the following sum function works for any type that supports construction from 0 and addition :
     109\label{s:ParametricPolymorphism}
     110Routines in \CFA can also be reused for multiple types. This capability is done using the \code{forall} clauses, which allow separately compiled routines to support generic usage over multiple types. For example, the following sum function works for any type that supports construction from 0 and addition:
    110111\begin{cfacode}
    111112//constraint type, 0 and +
     
    124125Since writing constraints on types can become cumbersome for more constrained functions, \CFA also has the concept of traits. Traits are named collection of constraints that can be used both instead and in addition to regular constraints:
    125126\begin{cfacode}
    126 trait sumable( otype T ) {
     127trait summable( otype T ) {
    127128        void ?{}(T *, zero_t);          //constructor from 0 literal
    128129        T ?+?(T, T);                            //assortment of additions
     
    131132        T ?++(T *);
    132133};
    133 forall( otype T | sumable(T) )  //use trait
     134forall( otype T | summable(T) ) //use trait
    134135T sum(T a[], size_t size);
    135136\end{cfacode}
     
    139140% ======================================================================
    140141\section{with Clause/Statement}
    141 Since \CFA lacks the concept of a receiver, certain functions end-up needing to repeat variable names often. To remove this inconvenience, \CFA provides the \code{with} statement, which opens an aggregate scope making its fields directly accessible (like Pascal).
     142Since \CFA lacks the concept of a receiver, certain functions end up needing to repeat variable names often. To remove this inconvenience, \CFA provides the \code{with} statement, which opens an aggregate scope making its fields directly accessible (like Pascal).
    142143\begin{cfacode}
    143144struct S { int i, j; };
Note: See TracChangeset for help on using the changeset viewer.