From: "David A. Black" Date: 2007-11-08T20:54:48+09:00 Subject: Re: Metaclasses Hi -- On Thu, 8 Nov 2007, Rick DeNatale wrote: > On 11/8/07, David A. Black wrote: > >> It actually depends which version of Ruby you use. The superclass >> thing worked as expected in 1.8.2; then it stopped working (I'm not >> sure why); and in 1.9 it's working again. ("Not working" doesn't mean >> that the subclasses couldn't call the methods defined in their >> superclasses' singleton classes, just that the superclass thing itself >> was not in place.) > > interesting, I didn't realize that this had changed in 1.9. > > Actually, it's not that anything isn't in place in 1.8, it's that the > implementation of Class#superclass skips classes in the superclass > chain, the same way that Object#class skips an instance singleton > class if there is one, and the ancestors methods replaces the wrapper > IClass nodes used to represent included modules in the behavior chain > of an object into the modules themselves in the result. By "superclass thing itself not in place" I just meant that you get false when you ask whether C's singleton class is the superclass of D's singleton class. So any documentation/books/etc. that describe it that way will seem wrong if you try it out in 1.8.6. > It's smoke and mirrors, and in the case of Ruby 1.9 it seems theres a > little less smoke and mirrors in Class#superclass. Always a good sign :-) David -- Upcoming training by David A. Black/Ruby Power and Light, LLC: * Advancing With Rails, Edison, NJ, November 6-9 * Advancing With Rails, Berlin, Germany, November 19-22 * Intro to Rails, London, UK, December 3-6 (by Skills Matter) See http://www.rubypal.com for details!