From: Rick DeNatale Date: 2008-03-23T07:28:32+09:00 Subject: Re: #meta On 3/22/08, Trans wrote: > > I also side with Jim Weirich about the > > distinction between metaclass and singleton class or eigenclass or > > whatever you want to call them. > > > That's Smalltalk not Ruby. I understand the distinction people want to > draw, but in Ruby they are the same construct. I respectfully disgree. Singleton classes in Ruby are an implementation construct which is used for two distinct purposes: 1) To provide a place to put instance behavior. For example a = "abc" def a.foo :foo end 2) To provide a class for a class, i.e. a metaclass. One difference is that the first can't have subclasses, while singleton classes used as metaclasses can and must since the inheritance chain of metaclasses parallels the inheritance chain of their instances. The otehr is that metaclasses is the class of a class, not an arbitrary object. For all practical purposes, the second kind acts exactly as metaclasses do in Smalltalk, and Matz was quoted as such in the 2nd ed of the Pickaxe. Unfortunately many in the Ruby community misunderstood that page as equating metaclass with singleton class rather than seeing that although singleton classes are used to implement metaclasses in Ruby, all singleton classes are NOT metaclasses, a term which has a meaning even beyond Smalltalk of being the class of a class. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/