#!/usr/local/bin/rune -x # # Demonstrate constant types. Constants in Rune are effectively what # '#define BLAH 23' would be in C, except they are specifically typed. # import "sys"; import ; alias stdio.File @stdout = stdio.stdout; const char NIL = 0UB; const int FUTZ = 55; class TestClass { global const int ELEMENTS = 64; global const int Y = ELEMENTS + 1; global const int Z = ELEMENTS + 1; char buf[ELEMENTS]; } subclass TestClass as SubTestClass { refine global const int Z = 99; } public int main(int ac, string_p *av) { int len; int i; string_p str; TestClass test; SubTestClass test2; stdout->show("Eval global constant (65) ", test.Z); stdout->show("Eval global constant (99) ", test2.Z); stdout->show("Eval global constant (55) ", FUTZ); for (i = 0; i < 10; ++i) { len = 1 + 2 * 3; } stdout->show("Array size (64): ", arysize(test.buf)); stdout->show("Constant evaluated to (7): ", len); stdout->show("Testclass Y (65): ", TestClass.Y); stdout->show("ac = ", ac); str = av[ac - 1]; for (len = 0; str[len] != NIL; ++len) ; stdout->show("argv[argc-1] = ", str); return(len); }