Changeset 1dc6df0 for doc


Ignore:
Timestamp:
Apr 16, 2017, 9:45:31 AM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
0aad606
Parents:
4635c79
Message:

additional cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/generic_types/generic_types.tex

    r4635c79 r1dc6df0  
    257257For example, it is possible to write a type-safe \CFA wrapper @malloc@ based on the C @malloc@:
    258258\begin{lstlisting}
    259 forall( dtype T | sized(T) ) T * malloc( void ) { return (T *)(void *)malloc( (size_t)sizeof(T) ); }
     259forall( dtype T | sized(T) ) T * malloc( void ) { return (T *)malloc( sizeof(T) ); }
    260260int * ip = malloc();                                            $\C{// select type and size from left-hand side}$
    261261double * dp = malloc();
     
    505505Consider 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}
    507 typedef struct { int quo, rem; } div_t;
     507typedef struct { int quo, rem; } div_t;         $\C{// from include stdlib.h}$
    508508div_t div( int num, int den );
    509509double remquo( double num, double den, int * quo );
     
    759759\begin{lstlisting}
    760760int f( [int, double], double );
    761 forall(otype T, otype U | { T f( T, U, U ); })
    762 void g( T, U );
     761forall(otype T, otype U | { T f( T, U, U ); }) void g( T, U );
    763762g( 5, 10.21 );
    764763\end{lstlisting}
     
    767766Whenever a candidate's parameter structure does not exactly match the formal parameter's structure, a thunk is generated to specialize calls to the actual function:
    768767\begin{lstlisting}
    769 int _thunk( int _p0, double _p1, double _p2 ) {
    770         return f( [_p0, _p1], _p2 );
    771 }
     768int _thunk( int _p0, double _p1, double _p2 ) { return f( [_p0, _p1], _p2 ); }
    772769\end{lstlisting}
    773770so the thunk provides flattening and structuring conversions to inferred functions, improving the compatibility of tuples and polymorphism.
Note: See TracChangeset for help on using the changeset viewer.