David A. Black wrote: > > I don't know what the term refers to in Python, but I do know that in > Ruby there's been a lot of terminological slippage over the years. > Some people use "metaclass" to refer to all singleton classes. Others > use it to refer to the singleton classes of class objects. Other have > argued that the only real metaclass in Ruby is the class Class (if you > define a metaclass as a class that produces classes). Well said. I would fall into the last camp. Some people object to the term "singleton class." Matz has suggested many alternatives, such as "singular class" (which I rather like). I confess I also like "eigenclass" but I won't push for it. Whatever it is, though, it isn't a metaclass. > Singleton classes in general are definitely not deep magic. They're > just the way Ruby handles requests for per-object method definitions: > stick them in a per-object class. They're not particularly meta; > they're just anonymous classes. It has always bothered me a tiny bit to call them classes at all; after all, you can't instantiate them. What kind of class has no instances? The Unicorn class perhaps? > Singleton classes of class objects are probably the most frequently > made use of, since that's where class methods live. I think you see > this: > > class C > class << self > > more often than class << obj where obj is not a class. Probably true. > And class Class is just class Class :-) Ha, it makes so much sense in writing, but tell it to a blind guy. > So the question of what "metaclasses" allow you to do depends a bit on > what you mean exactly, but I don't think there's much mystery or > reason for people not to try to understand them. Definitely agreed. Hal