[Nickle] global
Bart Massey
nickle@nickle.org
Thu, 29 May 2003 08:45:57 -0700
In message <E19LOIi-0002cs-00@localhost> you wrote:
> 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.
This brings up the related issue that I again had to work
around the fact that since each top-level statement is
evaluated in its own thread, I had to work around using
continuations at top level. Pretty clearly we have some
issues here we'll have to think about. I think my vote is
to execute each whole input in script mode, or each
interactive statement in interactive mode, in an anonymous
top-level "global" scope. Does this make sense?
> $ 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?
Not that I can think of.
Bart