Sporking class member causes NullPointerException?
I tried this: class Test{ 0=>int iz; fun void initTest(){ while(true){ <<<iz>>>; ++iz; 10::ms=>now; } } spork ~ initTest(); } Test o; And got this: [chuck](VM): NullPointerException: shred[id=2:spork~exp], PC=[3] The same code works perfectly when putting the fun reference and spork outside of the class definition. Is there any way around this, iow a way to start a shred from a instanciated object? /nitro2k01 -- -----BEGIN 2ROT13 MESSAGE----- The blog of nitro2k01: http://soundandcomplete.wordpress.com/ Sätt på ett par flipflops, vippa på rumpan och gör det här till en minnesvärd sommar! -----END 2ROT13 MESSAGE-----
nitro2k01 wrote:
Is there any way around this, iow a way to start a shred from a instanciated object?
This is a known issue and I believe it's being worked on. For now (if possible for what you want) declare initTest and iz as static: class Test{ 0=> static int iz; fun static void initTest(){ while(true){ <<<iz>>>; ++iz; 10::ms=>now; } } spork ~ initTest(); } Test o; while(true){ 1::week => now; } -- peace, love & harmony Atte http://www.atte.dk | quartet: http://www.anagrammer.dk http://www.atte.dk/gps | compositions: http://www.atte.dk/compositions
On 6/28/06, Atte André Jensen
This is a known issue and I believe it's being worked on. For now (if possible for what you want) declare initTest and iz as static:
Well, the idea of putting things in a class is being able to have multiple instances, so I guess I'll skip the class definition for now until this gets fixed. Thanks anyway. /nitro2k01 -- -----BEGIN 2ROT13 MESSAGE----- The blog of nitro2k01: http://soundandcomplete.wordpress.com/ Sätt på ett par flipflops, vippa på rumpan och gör det här till en minnesvärd sommar! -----END 2ROT13 MESSAGE-----
// Here is a work around for sporking member functions, ghastly but effectively. class Test { 0 => int iz; fun void initTest() { while(true) { <<<iz>>>; ++iz; 10::ms=>now; } } fun static void lame( Test test ) { test.initTest(); } spork ~ lame( this ); } Test o; while( true ) 1::second => now; On Jun 28, 2006, at 4:48 PM, nitro2k01 wrote:
On 6/28/06, Atte André Jensen
wrote: This is a known issue and I believe it's being worked on. For now (if possible for what you want) declare initTest and iz as static:
Well, the idea of putting things in a class is being able to have multiple instances, so I guess I'll skip the class definition for now until this gets fixed. Thanks anyway.
/nitro2k01
-- -----BEGIN 2ROT13 MESSAGE----- The blog of nitro2k01: http://soundandcomplete.wordpress.com/ Sätt på ett par flipflops, vippa på rumpan och gör det här till en minnesvärd sommar! -----END 2ROT13 MESSAGE----- _______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (3)
-
Atte André Jensen
-
Ge Wang
-
nitro2k01