...or at least as consistent as possible, taking into account the differences that do exist between class handling in Java and ChucK. In Java it's stated that static members are instantiated when classes are loaded, as part of the dynamic loading of classes - each is stored in its own file. ChucK doesn't load classes in this way, but since Java classes are usually loaded when they are first referenced, the effect is pretty much the same in the two languages.

I'm guessing you want to do some kind of namespace encapsulation? It would be a cool thing to be able to create your own equivalents of Std and Math (maybe I'm ignorant and you already can...)

/Stefan

On Tue, Nov 24, 2009 at 10:47 PM, Stefan Blixt <stefan.blixt@gmail.com> wrote:
Not necessarily a bug. Again, consistent with how Java works with classes (I sometimes wonder if Ge got hold of the Java compiler source code cheap ;)

/Stefan


On Tue, Nov 24, 2009 at 7:51 PM, Hans Aberg <haberg@math.su.se> wrote:
For some reason, 'chuck' does not instantiate class static constants until there has been an instantiation of the class itself.

 Hans

---- static.ck ----
class Test {
 3 => static int d;

 fun static void print() {
   if (d == 0)  chout <= "Nope!\n";
   else  chout <= "Yep.\n";
 }
}

Test.print();
Test test_;
Test.print();

---- run ----
$ chuck static.ck
Nope!
Yep.
----

_______________________________________________
chuck-users mailing list
chuck-users@lists.cs.princeton.edu
https://lists.cs.princeton.edu/mailman/listinfo/chuck-users



--
Release me, insect, or I will destroy the Cosmos!



--
Release me, insect, or I will destroy the Cosmos!