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

mike clemow gelfmuse at gmail.com
Wed Jan 21 16:39:03 EST 2009


Kassen,

Yeah, that implementation is a good work around.  I agree about
popBack() going on the bug list.

Here's a concise demo:

Object objects[0];
SinOsc s;
objects << s;

SinOsc s1;
// should return type Object.  Instead returns type void.
objects.popBack() $ SinOsc @=> s1;

Where should I post this?

-Mike

On Wed, Jan 21, 2009 at 4:19 PM, Kassen <signal.automatique at gmail.com> wrote:
> 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.
>
> Yours,
> Kas.
>
> class Collection {
>        Object objects[0];
>        0 => int count;
>
>        fun void add( Object obj ) {
>                objects << obj;
>                count++;
>        }
>
>        // this you can't do, apparently...
>        fun Object pop() {
>                objects[count-1] @=> Object s;
>                count--;
>                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
> f.signal();
> <<< myCollection.count >>>;
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>
>



-- 
http://michaelclemow.com
http://semiotech.org


More information about the chuck-users mailing list