[chuck-users] .size() fails to properly instantiate objects

Kassen signal.automatique at gmail.com
Sun Aug 10 15:35:49 EDT 2008

Fellow ChucKists,

Below you'll find some example code proving that extending a array of
instances of a home-made class using ".size()"doesn't properly instantiates
the new objects, leading to nullpointers and the shred being dropped. The
"<<" operator, using "new" does lead to proper instantiation.

I feel this is a bug.



//instantiate a array of home made classes
foo bar[1];

//check that this works
<<<"your lucky number is ", bar[0].value>>>;

//grow by one.
bar << new foo ;

//make sure it's instantiated
<<<"your lucky number is ", bar[1].value>>>;

//grow by a another one
bar.size(bar.size() + 1);

//make sure we did, size should now be 3
<<<"size is now", bar.size()>>>;

//try to verify this is instantiated, it won't be
<<<"your unlucky number is ", bar[2].value>>>;

class foo
    Std.rand2(0, 10) => int value;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20080810/acda50ef/attachment.html>

More information about the chuck-users mailing list