Quote:
>I am having trouble to understand what a Metaclass is. If I understand
>correctly, it is a class that has a unique instance which is a class. Is it
>usual to have classes as instances of class? Also, what would be the use of a
>class whitout instances (abstract class right?)? Is it to encapsulate
>behavior, or adding functionality without changing the superclass? Thanks,
Everything in Smalltalk is an object, including classes. Every object
has a class, including classes. The class of a class is a special
kind of class called a metaclass. "Array" is a class. "Array class"
is a metaclass. Metaclasses have one instance, and they don't have
a name, but share their one instance's name. "Array class" stores
the methods that are used to implement messages to the class "Array",
hence metaclasses hold class methods.
An abstract class does more than just encapsulate behavior, it acts
as a template for its concrete subclasses. In Smalltalk, Object, Collection,
Number, and Stream are all abstract classes.
-Ralph Johnson