Changeset 10e0fcd for doc


Ignore:
Timestamp:
Apr 16, 2017, 10:42:15 AM (8 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:
19b2133
Parents:
0aad606
Message:

fix malloc calls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/generic_types/generic_types.tex

    r0aad606 r10e0fcd  
    823823struct S { int x, y; };
    824824forall(otype T, ttype Params | { void print(T); void print(Params); }) void print(T arg, Params rest) {
    825         print(arg);
    826         print(rest);
     825        print(arg);  print(rest);
    827826}
    828827void print( char * x ) { printf( "%s", x ); }
     
    839838For example, it is possible to write @new@ as a library function:
    840839\begin{lstlisting}
    841 struct pair( otype R, otype S );
    842 forall( otype R, otype S ) void ?{}( pair(R, S) *, R, S );  // (1)
     840forall( otype R, otype S ) void ?{}( pair(R, S) *, R, S );
    843841forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } ) T * new( Params p ) {
    844         return ((T *)malloc( sizeof(T) )){ p }; // construct into result of malloc
     842        return ((T *)malloc()){ p };                    $\C{// construct into result of malloc}$
    845843}
    846844pair( int, char ) * x = new( 42, '!' );
Note: See TracChangeset for help on using the changeset viewer.