Malte Ubl wrote:
> Dan Sugalski wrote:
> > So, if I understand this right (and I may well not), when you
> > instantiate a metaclass you get a class, and when you instantiate a 
> > class you get an object, and since anything you instantiate is an object 
> > anyway that means classes are objects. I'm not entirely sure if 
> > metaclasses are objects, but it seems to lack a certain amount of 
> > egregious symmetry if it doesn't.

> Meta classes break the "every class has a super class"-chain by 
> inheriting from themselves. A natural meta class is the word noun. It 
> describes a class of words and it is an instance of that class.

In many languages like Squeak, this is not quite true.  Classes are
instances of Metaclass, and Metaclass is an instance of the Metaclass class,
so the circular reference occurs in the instantiation hierarchy and not the
inheritance hierarchy.  So for some instance abc of the ABC class which
inherits from Object, we have

(instance hierarchy)
abc -> ABC -> ABC class -> Metaclass -> Metaclass class -> Metaclass

(inheritance hierarchy (simplified from Squeak))
ABC ->                         Object
Metaclass       -> Behavior -> Object
Metaclass class -> Behavior -> Object

In languages such as Squeak, Smalltalk and Actor, "every" class does not
inherit from themselves.  There are usually only two "special" classes,
like Metaclass and Behavior.  Metaclass instantiates the class of classes
and in turn is an instance of one of its objects, the Metaclass class.

Behavior is the superclass of all classes which in turn has Object as its
Superclass.  In this way, all objects are instances of classes which have
Object as their superclass.

Metaclasses are objects (in languages like Squeak, Smalltalk and Actor).

Mark Solinski

"The fox knows many tricks. The hedgehog knows one. One good one."
  -- Archilochus

Reply via email to