Changes in src/tests/Forall.c [a0dcd2e:62edde5]
- File:
-
- 1 edited
-
src/tests/Forall.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/tests/Forall.c
ra0dcd2e r62edde5 7 7 8 8 void g1() { 9 forall( otype T ) T f( T );9 forall( type T ) T f( T ); 10 10 void f( int ); 11 11 void h( void (*p)(void) ); … … 24 24 25 25 void g2() { 26 forall( otype T ) void f( T, T );27 forall( otype T, otype U ) void f( T, U );26 forall( type T ) void f( T, T ); 27 forall( type T, type U ) void f( T, U ); 28 28 29 29 int x; … … 37 37 } 38 38 39 typedef forall ( otype T ) int (*f)( int );39 typedef forall ( type T ) int (*f)( int ); 40 40 41 forall( otype T )41 forall( type T ) 42 42 void swap( T left, T right ) { 43 43 T temp = left; … … 46 46 } 47 47 48 trait sumable( otype T ) {48 context sumable( type T ) { 49 49 const T 0; 50 50 T ?+?(T, T); … … 53 53 }; 54 54 55 otype T1 | { const T1 0; T1 ?+?(T1, T1); T1 ?++(T1); [T1] ?+=?(T1,T1); },56 T2( otype P1, otype P2 ),55 type T1 | { const T1 0; T1 ?+?(T1, T1); T1 ?++(T1); [T1] ?+=?(T1,T1); }, 56 T2(type P1, type P2 ), 57 57 T3 | sumable(T3); 58 58 59 otype T2(otype P1, otype P2) | sumable(T2(P1,P2)) = struct { P1 i; P2 j; };59 type T2(type P1, type P2) | sumable(T2(P1,P2)) = struct { P1 i; P2 j; }; 60 60 61 61 T2(int, int) w1; 62 62 typedef T2(int, int) w2; 63 63 w2 g2; 64 otype w3 = T2(int, int);64 type w3 = T2(int, int); 65 65 w3 g3; 66 66 67 forall( otype T | sumable( T ) )67 forall( type T | sumable( T ) ) 68 68 T sum( int n, T a[] ) { 69 69 T total = 0; … … 74 74 } 75 75 76 forall( otype T | { const T 0; T ?+?(T, T); T ?++(T); [T] ?+=?(T,T); } )76 forall( type T | { const T 0; T ?+?(T, T); T ?++(T); [T] ?+=?(T,T); } ) 77 77 T twice( T t ) { 78 78 return t + t; 79 79 } 80 80 81 forall( otype T | { const T 0; int ?!=?(T, T); int ?<?(T, T); } )81 forall( type T | { const T 0; int ?!=?(T, T); int ?<?(T, T); } ) 82 82 T min( T t1, T t2 ) { 83 83 return t1 < t2 ? t1 : t2;
Note:
See TracChangeset
for help on using the changeset viewer.