1 #!/usr/local/bin/rune -x
3 # Demonstrate the use of defaults for type and procedure arguments.
4 # elements with defaults are optional. Use slightly more complex
5 # expressions to ensure that temporary storage is properly allocated
8 # Note that as with C, Rune does not guarentee the order of evaluation
9 # for procedural arguments... or for compound expressions for that
10 # matter. XXX we probably should.
15 alias stdio.File *stdout = stdio.stdout;
30 typedef int myint_t = 4 + 0 + (0 * 0);
33 main(int ac, char **av)
36 (int a = 4, Fubar b) y = (b:(b:1000));
40 stdout->show("This should be 4:", y.b.a);
41 stdout->show("This should be 1000:", y.b.b);
43 i = fubar(7); # b's default will be returned
44 stdout->show("This should be 5:", i);
46 stdout->show("This should be 9:", i);
48 stdout->show("This should be 4:", ptr->a);
49 stdout->show("This should be 20:", ptr->b);
50 stdout->show("This should be 1:", ptr->c);
52 stdout->show("This should be 4:", flub.a);
53 stdout->show("This should be 20:", flub.b);
54 stdout->show("This should be 1:", flub.c);
60 fubar(int a, int b = 5)