Rune - Content-locking work 1/2
[rune.git] / tests / pure.d
1 #!/usr/local/bin/rune -x
2 #
3 # Demonstrate constant types.   Constants in Rune are effectively what
4 # '#define BLAH 23' would be in C, except they are specifically typed.
5 #
6 # Demonstrate a resolve-time constant (the array size for fu[]).  The
7 # resolver drills the resolution by executing the interpreter and requires
8 # a constant return value.  Note that no global storage is available when
9 # doing this, but the resolver will shortcut through any variable assignments
10 # to avoid having to instantiate and fully initialize the global SemGroup.
11
12 limport "sys";
13 import "stdio";
14
15 const int charlie = fubar();
16 const int fu[charlie];
17
18 pure int
19 fubar(void)
20 {
21         return 55;
22 }
23
24 public 
25 int
26 main(int ac, char **av)
27 {
28         stdio.stdout->show("fubar 55:", charlie);
29         fu[0] = 1;
30         fu[54] = 1;
31 }
32