#!/usr/local/bin/rune -x # # Demonstrate the use of defaults for type and procedure arguments. # elements with defaults are optional. Use slightly more complex # expressions to ensure that temporary storage is properly allocated # to resolve them. # # Note that as with C, Rune does not guarentee the order of evaluation # for procedural arguments... or for compound expressions for that # matter. XXX we probably should. import "sys"; import ; alias stdio.File @stdout = stdio.stdout; struct Fubar { myint_t a; int b = 20 - 0; int c = 3 + 0; constructor method void bleh() { this->c = 1; } } typedef int myint_t = 4 + 0 + (0 * 0); int main(int ac, string_p *av) { int32_t i = 100; (int a = 4, Fubar b) y = (b:(b:1000)); Fubar *ptr; Fubar flub; stdout->show("This should be 4:", y.b.a); stdout->show("This should be 1000:", y.b.b); i = fubar(7); # b's default will be returned stdout->show("This should be 5:", i); i = fubar(b:9, a:3); stdout->show("This should be 9:", i); ptr.new(); stdout->show("This should be 4:", ptr->a); stdout->show("This should be 20:", ptr->b); stdout->show("This should be 1:", ptr->c); stdout->show("This should be 4:", flub.a); stdout->show("This should be 20:", flub.b); stdout->show("This should be 1:", flub.c); return(0); } int fubar(int a, int b = 5) { return(b); }