On 8/25/06, Trans [email protected] wrote:
At the very least, ‘singleton_class’ is too long. Just ‘singleton’
would suffice.
Alas, I wish we could just go back to ‘metaclass’.
It’s probably my Smalltalk background, but metaclass bothers me as a
name for a singleton class which holds INSTANCE specific methods for a
non-class.
On the other hand, metaclass fits perfectly in my mind for naming a
singleton class of a CLASS which holds the class methods for that
class.
The fact that in the ruby implementation, both of these are singleton
classes is an accident of implementation (in the sense of accidental
being the antonym of essential). Now if I might dredge up some
Smalltalk terminology, I might suggest that we call:
The singleton class of an instance its 'behavior' and
The singleton class of a class its 'metaclass.'
Classes are about representing a ‘class’ of instances: instantiating
them and providing common behavior. Despite what folks like why have
written, metaclasses really should be considered something which is a
feature of classes and not any arbitrary object. That’s why the word
is metaCLASS.
The term ‘behavior’ here, as is about simply having behavior (i.e. a
set of methods).
Of course all three of these things (behavior, class, and metaclass)
are also just links on the chain of objects which define all the
methods inherited by an object, or a class.
The more I think about this the more I like the terminology,
But that’s just what I think.
–
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denhaven2.com/