MenTaLguY wrote:
> On Thu, 2007-03-29 at 08:30 +0900, John Lam (CLR) wrote:
>> More interestingly though, is where does the new method comes from
>> when doing A.new. We believe that once we've looked at all of the
>> ancestor classes' eigenclasses for new, that we then hit the Class and
>> Module classes in the list of eigenclasses. Does that make sense as
>> well? It's a bit strange because you start off looking through the
>> eigenclass hierarchy for new, and then switch to the class hierarchy
>> at the very end for Class, Module and Object.
> 
> I don't see it being particularly strange -- once we exhaust the
> applicable eigenclasses, we start looking at the class hierarchy for the
> class's _class_ (Class), just as we do for any other object.  The only
> difference is that for class objects we consider more than just the
> object's own eigenclass, including also the class's ancestors (not the
> class's class's ancestors).
> 
>> Is this how things are actually implemented? (BTW I'm not lazy here -
>> we cannot look for ourselves).
> 
> More or less.

Ditto in JRuby. It wasn't always this way, but by pragmatically fixing 
what broke as we ran more and more code, we've arrived at basically the 
same place. And then recently a community member went through and tied 
up all the loose ends. A great amount of work on the 
metaclass/class/eigenclass/singleton class magic was required to get 
Rails running, for example, and it's employed heavily in a number of 
Ruby's own standard libraries.

- Charlie