[chuck-users] object / class hacking
Robert Poor
rdpoor at gmail.com
Tue Sep 29 20:13:11 EDT 2009
Chucksters:
Three questions in one message (generally a bad idea, but they're
short):
[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.)
[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:
public class Foo {
Controller @ c;
fun void init(Controller c) { c @=> this.c }
}
Foo foo;
foo.init(x);
[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.
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?
TIA.
- rob
More information about the chuck-users
mailing list