From: Peter Vandenabeele Date: 2010-12-06T21:32:46+09:00 Subject: Re: Singleton class, metaclass, eigenclass: what do they mean? On Mon, Dec 6, 2010 at 3:00 AM, Rick DeNatale wrote: > On Sun, Dec 5, 2010 at 6:49 PM, Peter Vandenabeele > wrote: >> On Sun, Dec 5, 2010 at 11:49 PM, Rick DeNatale wrote: >> ... >>>>> The 'things' pointed to by klass pointers are either: >>>> >>>> Could this be a typo where you intended to say 'super' pointers? >>> >>> I think I should have said klass or superclass pointers. >> >> If I see correctly, those are really different things. The klass >> pointers for all "regular" classes (Class objects) and for virtual >> classes (singleton classes (of an object) and metaclasses (of a >> class), to follow your terminology) are all uniformily pointing to >> the Class object, so not much to see there ... What I was >> discussing is the 'super' chain that is relevant for method lookup. > > No, the klass pointer in the object header points to the beginning of > the chain of structures (in the C language sense) which point to > method tables to search for method lookup, the superclass pointer is > the 'next' link in those chains. > > In the case of an object with singleton methods, klass will point to > the singleton class and it's superclass pointer will either point to > the objects 'real' class or to a chain of one or more module proxies > inserted before that class if the object has extended any module. I believe the confusion is that this is the case for "regular objects" and their singleton classes, but I discussed the special case of "class objects" and their singleton classes (aka metaclasses). For "class objects" (e.g. class A; end), the behavior of the 'super' pointer is different from this standard scheme, to implement inheritance of class methods: (A.singleton_class.superclass == A.superclass.singleton_class and A.singleton_class.superclass != A.class). Thanks for your time discussing this, Peter