- Timestamp:
- Nov 16, 2016, 4:37:50 PM (8 years ago)
- 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:
- 186fd86
- Parents:
- 33a7b6d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/tests/tupleFunction.c
r33a7b6d rd9fa60a 51 51 } 52 52 53 // forall(otype T | { T ?+?(T, T); }) 54 // [T, T, T] ?+?([T, T, T] x, [T, T, T] y) { 55 // T x1, x2, x3, y1, y2, y3; 56 // [x1, x2, x3] = x; 57 // [y1, y2, y3] = y; 58 // return [x1+y1, x2+y2, x3+y3]; 59 // } 53 int main() { 54 [int, double, int] x = [777, 2.76, 8675]; 55 int x1 = 123, x3 = 456; 56 double x2 = 999.123; 60 57 61 int main() { 62 [int, double, int] x = [777, 2.76, 8675]; 63 int x1 = 123, x3 = 456; 64 double x2 = 999.123; 65 66 printf("foo(...)=%d\n", foo(x1, x3, x2, (S){ 321, 654, 'Q', 3.14 })); 58 printf("foo(...)=%d\n", foo(x1, x3, x2, (S){ 321, 654, 'Q', 3.14 })); 67 59 68 60 // call function with tuple parameter using tuple variable arg … … 91 83 [x1, x2, x3] = quux(); 92 84 printf("x1=%d x2=%lg x3=%d\n", x1, x2, x3); 85 86 // xxx - tuples of type parameters should come out as generic types? 87 // [x1, x2, x3] = ([(int)x1, (int)x2, (int)x3]) + ([(int)1, (int)2, (int)3]); 88 // ([(int)x1, (int)x2, (int)x3]) + ([(int)1, (int)2, (int)3]); 89 // printf("%d %g %d\n", x1, x2, x3); 90 91 // xxx - comes out the back as a cast, but should come out as a tuple expression of the first n fields cast to each of the result types 92 // ([int, double])x; 93 93 } 94 94
Note: See TracChangeset
for help on using the changeset viewer.