1 #!/usr/local/bin/rune -x
3 # Demonstrate a user-defined operator. We demonstrate two types
4 # of operators.. one which is pass-by-value, another which is
10 alias stdio.File @stdout = stdio.stdout;
18 myfunc (Test lhs, Test rhs) {
19 lhs.a = lhs.a + rhs.a;
20 lhs.b = lhs.b - rhs.b;
26 myfunc (lvalue Test lhs, int rhs) {
33 # Rune is allowed to optimize a procedure's return value if the procedure
34 # returns a const (e.g. char * const or const int, NOT const char *)
35 # and the arguments supplied to the procedure are constants or constant
36 # evaluated expressions. This works recursively and can massively optimize
40 blech(int lhs, int rhs)
42 stdout->show("this message should only print twice");
47 main(int ac, string_p *av)
58 z = x +++ y; # z should be (12, -2)
59 z %%= 23; # z should be (35, -46)
60 stdout->show("z.a (should be 35) ", z.a, " z.b (should be -46) ", z.b);
62 stdout->show("looping ", blech(10000000, 1));
65 # Rune should be able to optimize out the call to blech()
67 for (i = 0; i < blech(10000000, 1); ++i)
74 for (i = 0; i < 4; ++i) {
75 stdout->fputc(*--str);