Ignore:
Timestamp:
Sep 24, 2015, 9:59:20 PM (9 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
02e5ab6
Parents:
bfee448
Message:

make *predefined* declarations work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/refrat/refrat.tex

    rbfee448 r20e409e  
    254254\subsubsection{Semantics}
    255255
    256 CFA provides a capability for generic types; using this capability a single "generic type generator"
    257 can be written that can represent multiple concrete type instantiations by substitution of the "type
    258 parameters" of the generic type for concrete types. Syntactically a generic type generator is
    259 represented by putting a forall specifier on a struct or union declaration, as defined in section
    260 6.7.2.5. An instantiation of the generic type is written by specifying the type parameters in
    261 parentheses after the name of the generic type generator, as in the following example:
    262 \begin{lstlisting}
    263 forall( type T ) struct pair {
     256\CFA provides a capability for generic types; using this capability a single "generic type
     257generator" can be written that can represent multiple concrete type instantiations by substitution
     258of the "type parameters" of the generic type for concrete types. Syntactically a generic type
     259generator is represented by putting a forall specifier on a struct or union declaration, as defined
     260in \VRef{forall}. An instantiation of the generic type is written by specifying the type parameters
     261in parentheses after the name of the generic type generator:
     262\begin{lstlisting}
     263forall( type T | sumable( T ) ) struct pair {
    264264        T x;
    265265        T y;
    266266};
    267 
    268267pair( int ) p = { 3, 14 };
    269268\end{lstlisting}
    270269
    271270The type parameters in an instantiation of a generic type must satisfy any constraints in the forall
    272 specifier on the type generator declaration. The instantiation then has the semantics that would
    273 result if the type parameters were substituted into the type generator declaration by macro
    274 substitution.
     271specifier on the type generator declaration, e.g., \lstinline$sumable$. The instantiation then has
     272the semantics that would result if the type parameters were substituted into the type generator
     273declaration by macro substitution.
    275274
    276275Polymorphic functions may have generic types as parameters, and those generic types may use type
    277 parameters of the polymorphic function as type parameters of the generic type, as in the following
    278 example:
     276parameters of the polymorphic function as type parameters of the generic type:
    279277\begin{lstlisting}
    280278forall( type T ) void swap( pair(T) *p ) {
Note: See TracChangeset for help on using the changeset viewer.