Changeset ffc9f5a for doc


Ignore:
Timestamp:
Apr 13, 2017, 8:17:28 AM (7 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, resolv-new, with_gc
Children:
5103d7a
Parents:
19518e8
Message:

fixed a few typos in generic types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/generic_types/generic_types.tex

    r19518e8 rffc9f5a  
    342342% int is_nominal;                                                               $\C{// int now satisfies the nominal trait}$
    343343% \end{lstlisting}
    344 % 
     344%
    345345% Traits, however, are significantly more powerful than nominal-inheritance interfaces; most notably, traits may be used to declare a relationship \emph{among} multiple types, a property that may be difficult or impossible to represent in nominal-inheritance type systems:
    346346% \begin{lstlisting}
     
    353353% };
    354354% typedef list *list_iterator;
    355 % 
     355%
    356356% lvalue int *?( list_iterator it ) { return it->value; }
    357357% \end{lstlisting}
     
    503503In many languages, functions can return at most one value;
    504504however, many operations have multiple outcomes, some exceptional.
    505 Consider C's @div@ and @remquo@ functions, which return the quotient and remainder for a division of integer and floating-point values, respectively. 
     505Consider C's @div@ and @remquo@ functions, which return the quotient and remainder for a division of integer and floating-point values, respectively.
    506506\begin{lstlisting}
    507507typedef struct { int quo, rem; } div_t;
     
    524524\end{lstlisting}
    525525Clearly, this approach is straightforward to understand and use;
    526 therefore, why do most programming language not support this obvious feature or provide it awkwardly?
     526therefore, why do most programming languages not support this obvious feature or provide it awkwardly?
    527527The answer is that there are complex consequences that cascade through multiple aspects of the language, especially the type-system.
    528528This section show these consequences and how \CFA deals with them.
     
    532532
    533533The addition of multiple-return-value (MRV) functions are useless without a syntax for accepting multiple values at the call-site.
    534 The simplest mechanism for capturing the return values is variable assignment, allowing the valuse to be retrieved directly.
     534The simplest mechanism for capturing the return values is variable assignment, allowing the values to be retrieved directly.
    535535As such, \CFA allows assigning multiple values from a function into multiple variables, using a square-bracketed list of lvalue expressions (as above), called a \emph{tuple}.
    536536
    537 However, functions also use \emph{composition} (nested calls), with the direct consequence that MRV functions must also support composition to be orthogonal with single-returning-value (SRV) functions, \eg:
     537However, functions also use \emph{composition} (nested calls), with the direct consequence that MRV functions must also support composition to be orthogonal with single-return-value (SRV) functions, \eg:
    538538\begin{lstlisting}
    539539printf( "%d %d\n", div( 13, 5 ) );                      $\C{// return values seperated into arguments}$
     
    568568printf( "%d %d\n", qr );
    569569\end{lstlisting}
    570 \CFA also supports \emph{tuple indexing} to access single components of a typle expression:
     570\CFA also supports \emph{tuple indexing} to access single components of a tuple expression:
    571571\begin{lstlisting}
    572572[int, int] * p = &qr;                                           $\C{// tuple pointer}$
     
    606606In the call to @g@, the values @y@ and @10@ are structured into a single argument of type @[int, int]@ to match the parameter type of @g@.
    607607Finally, in the call to @h@, @x@ is flattened to yield an argument list of length 3, of which the first component of @x@ is passed as the first parameter of @h@, and the second component of @x@ and @y@ are structured into the second argument of type @[int, int]@.
    608 The flexible structure of tuples permits a simple and expressive function call syntax to work seamlessly with both SRF and MRF, and with any number of arguments of arbitrarily complex structure.
     608The flexible structure of tuples permits a simple and expressive function call syntax to work seamlessly with both SRV and MRV functions, and with any number of arguments of arbitrarily complex structure.
    609609
    610610
     
    734734f([5, "hello"]);
    735735\end{lstlisting}
    736 where @[5, "hello"]@ is flattened, giving argument list @5, "hello"@, and @T@ binds to @int@ and @U@ binds to @const char*@.
     736where @[5, "hello"]@ is flattened, giving argument list @5, "hello"@, and @T@ binds to @int@ and @U@ binds to @const char@.
    737737Tuples, however, may contain polymorphic components.
    738738For example, a plus operator can be written to add two triples together.
     
    869869                T2 field_2;
    870870        };
    871         _tuple3_(int, double, int) y;
     871        _tuple3(int, double, int) y;
    872872}
    873873\end{lstlisting}
Note: See TracChangeset for help on using the changeset viewer.