[chuck-users] parent and children classes (I meant polymorphism)

Kassen signal.automatique at gmail.com
Wed Jan 21 16:19:18 EST 2009

2009/1/21 Michael Heuer <heuermh at gmail.com>

> Are you sure that doesn't work?  I swear I have been doing the same
> with my collection classes.
I just tested it again to make absolutely sure.

objects.popBack() returns  "... :(void)" and

objects[count-1] returns something of type "object" so it seems like this is
a popback issue more than something that is fundamentally impossible.

Below is a corrected version that does work and IMHO .popBack() can go on
the bug list.


class Collection {
       Object objects[0];
       0 => int count;

       fun void add( Object obj ) {
               objects << obj;

       // this you can't do, apparently...
       fun Object pop() {
               objects[count-1] @=> Object s;
               objects.size( objects.size()-1);
               return s;

Collection myCollection;

SinOsc s;
Gain g;
Event e;

myCollection.add( s );
myCollection.add( g );
myCollection.add( e );

<<< myCollection.count >>>;

myCollection.pop() $ Event @=> Event f;

//make sure we can use it without crashing
<<< myCollection.count >>>;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20090121/ff13531b/attachment.htm>

More information about the chuck-users mailing list