From: Joshua Ballanco Date: 2009-05-14T13:57:53+09:00 Subject: Re: Superclass of eigenclass On May 13, 2009, at 6:10 PM, David Flanagan wrote: > On May 11, 5:42 am, Danny O cuiv wrote: >> Rick, Robert, >> >> Thanks again for your replies. >> >> Rick wrote: >>> If you go in and look at the implementation, you'll find that the >>> eigenclassof String has asuperclassslot which points to the >>> eigenclassof Object, but thesuperclassmethod implementation skips >>> past 'singleton' classes, until it gets to >> >> To me, that smacks of being ad hoc and inconsistent. Thesuperclass >> method implementation skips past 'singleton' classes, until it gets >> to >> #. But # is itself a 'singleton' class, >> so I >> can't see the rationale there. In other words, I can't really grasp >> what >> semantics are being exposed. > > The implementation details are leaking. No semantics should be read > into this, I think. > >> I'd have to confess that this seems like a conceptual mess to me. I >> presume that I'm grasping the wrong end of some stick or other. Can >> anyone help point out what that might be? > > It is a conceptual mess. It seems somewhat clearer, however, with > Ruby 1.9. I agree completely. In fact, beyond implementation detail, is there any reason that eigenclasses exist in their semi-privileged realm? For example, I've never completely understood why the following shouldn't work: >> class Test >> def eigenclass >> class<> self >> end >> end >> end => nil >> TestSubEigen = Class.new(Test.new.eigenclass) TypeError: can't make subclass of virtual class from (irb):43:in `initialize' from (irb):43:in `new' from (irb):43 In fact, it seems like the existence of eigenclasses is, to begin with, an implementation detail. As it turns out, they can be very handy for implementing instance-specific methods, but then isn't that the point of a Prototype inheritance model? Personally, I would like to see Ruby 2.0 formalize Ruby's prototyping abilities. The semantics of "Test.new" could remain the same and be conceptually identical to "Test.prototype.prototype". That is, eigenclasses would be prototype objects that sit between the object and its parent class object. This would have the added benefit of clearing up the method call chain concept, as it would simply follow the trail of prototypes. Just ideas... Cheers, Josh