1 #!/usr/local/bin/rune -x
3 # Demonstrate the use of lvalue scope. lvalue scope may be applied
4 # to individual procedural arguments or to the return value. It
5 # causes the caller to pass the object by reference instead of by
6 # value, allowing the procedure to modify the contents of the
9 # This feature is most often used when implementing operators that
10 # require lvalues, such as "++" and "&=", but it can be used to
11 # great effect with normal procedures as well.
16 alias stdio.File *stdout = stdio.stdout;
28 main(int ac, char **av)
32 Vector2 c = ( 15, 16 );
37 # this should fail because (1,1) is not an lvalue
40 stdout->show("Should get 100:", x.b);
42 # The ++ operator should return an lvalue, so this should
47 stdout->show("should get 3:", i);
49 # 'this' in the method is an lvalue and can modify
54 stdout->show("should get 17:", c.r);
59 # fubar() should be able to modify the caller's variable
62 fubar(lvalue (int a, int b) v, int w)