Robert;
[1] Accessing class name from an object
I seem to recall seeing a way to get an object to yield its class name, if only for printing. But I haven't been able to locate the e-mail thread where that was discussed. Was I hallucinating? (I really only want this for debugging, but if it's a supported function, it may be useful for dispatching on class type.)
Just try to "print the object", like this; Gain foo; //clearly a object <<< foo >>>;
[2] initializing an object
Is there a subclassable method that is called when you instantiate an object? or do have to instantiate then initialize manually, as in:
Not within ChucK as such, though the code that is in the body of the object itself (and outside of member functions) will run at instantiation, which seems to come down to a solution of your issue? This is provided we wrote the object ourselves, or extended it from a ready made one. Sadly UGens can't be extended in a working way.
[3] "natural" sorting of objects
Is there any attribute of an object that you can reliably use as a sort key? I ask because I want to speed up searching of an array of objects (e.g. to see if an object is already present). As I understand it, I can't use a hash array since there are no iterators.
Not within ChucK right now that I know of.
I guess the question should be: what's the fastest way to maintain a *set* of objects (i.e. a collection in which an object may only appear once) with the usual operations for insertion, deletion and iteration?
This sounds tricky, especially for the general case of sets that might include many different types of objects. You could keep them in a "set" by having a array of type Object and appending and assigning to that -I think- but I see no way to remove duplicates as I don't think the "==" operator covers objects in that general a way. I'm really not sure here. Erm.... good questions! ;-) Kas.