#!/usr/local/bin/rune -x # # Demonstrate the use of compound types. # import "sys"; import ; class Test { int a; int b = 7; } int main(int ac, char **av) { Fs fs; (int a, int b) x; (int a, int b = 7) t1 = (a:99); (int a, int b) t2 = (b:90); Test y; Test z; int i; stdio.stdout->show(" x should be (0, 0): ", x.a, x.b); stdio.stdout->show("t1 should be (99, 7): ", t1.a, t1.b); stdio.stdout->show("t2 should be (0, 90): ", t2.a, t2.b); stdio.stdout->show(" y should be (0, 7): ", y.a, y.b); fs.setfd(1); x = fubar(2); for (i = 0; i < x.b; ++i) fs.write("x", 1); y = fubar2(10); for (i = 0; i < y.b; ++i) fs.write("y", 1); fs.write("\n", 1); fs.write("xxxyyyyyyyyyyyyyyyyyyyy <-- should match\n", 42); z = fubar3(50); stdio.stdout->show(" x should be (55, 57): ", z.a, z.b); return(0); } (int a, int b = 3) fubar(int v) { # allow default for b to be returned # return(a:10); } Test fubar2(int v) { # maps to compound equivalance for Test (a, b), # overrides default. # return(v*1, v*2); } Test fubar3(int v) { # maps to compound equivalance for Test (a, b), # modifies default. # #return(a:5); return(a:v+3, b:v+7); }