[Nickle] global
Keith Packard
nickle@nickle.org
Thu, 29 May 2003 07:22:39 -0700
Around 1 o'clock on May 29, Bart Massey wrote:
> Looks like global isn't working right?
>
> $ nickle
> > for(int i = 0; i < 2; i++) {
> + global int[2] x = { 1, (printf("init\n"), 2) };
> + }
> init
> init
> >
Hmm. Global (and static) initializers that are defined inside functions
are placed in an anonymous lambda which is evaluated when the appropriate
function declaration is evaluated. Global initializers not inside a
function are simply evaluated in place. That's clearly broken, but
somewhat difficult to fix as there isn't a 'hook' to hang the initializer
code onto. I'll have to rework the compiler a bit to provide a place for
this initializer code to sit in this case. Fortunately the virtual machine
won't have to change at all.
$ nickle
> for(int i = 0; i < 2; i++) {
+ static int[2] x = { 1, (printf("init\n"), 2) };
+ }
<stdin>:2: Invalid storage class static
Somehow static is no longer a synonym for global at top level. Is there
any reason for it not to be?
-keith