[Aaaahhhhhh - lightning strikes] RE: [Q] mixin pattern - how to use an alternate Behavior for Class
n.schaerli at gmx.net
Tue Jan 29 06:59:25 UTC 2002
Yes, that's right, there are no -direct- instances of Class.
All the ST-80 "classes" (Object, Integer, etc.) are instances of their
metaclasses (Object class, Integer class, etc.) and these are again
instances of Metaclass.
However, since Object class, Integer class etc. are subclasses of Class (try
'Object class superclass superclass'), the ST-80 "classes" Object, Integer,
etc. are subinstances of Class. (Try 'Class allSubInstances').
1) The ST-80 "metaclasses" Object class, Integer class, etc. are subclasses
of Class and instances of Metaclass
2) The ST-80 "classes" Object, Integer, etc. are -instances- of subclasses
of Class (namely, of the metaclasses mentioned in 1).
> -----Original Message-----
> From: squeak-dev-admin at lists.squeakfoundation.org
> [mailto:squeak-dev-admin at lists.squeakfoundation.org]On Behalf Of
> Withers, Robert
> Sent: Monday, January 28, 2002 9:35 PM
> To: 'squeak-dev at lists.squeakfoundation.org'
> Subject: [Aaaahhhhhh - lightning strikes] RE: [Q] mixin pattern - how to
> use an alternate Behavior for Class
> Nathanael et al,
> I have just realized something. It's a classic 'aahhhh'
> situation with the
> meta-level of Smalltalk (this is true in VW as well). Do you
> realize that
> there are no instances of Class anywhere in the system. None, nada, zero,
> zip! Try doing 'Class allInstances' to prove it! What is true is that
> whatever the objects are, that represent classes, they are _subclasses_ of
> Class. Unbelievable!
> I wrote:
> > we can verify that these definition objects are instances of
> > the correct
> > class with:
> > Morph class isKindOf: Metaclass
> > Morph isKindOf: Class
> > Object class isKindOf: Metaclass
> > Object isKindOf: Class
> > and even:
> > ProtoObject class isKindOf: Metaclass
> > ProtoObject isKindOf: Class
> But the calls to <Class> isKindOf: Class is not doing what we think it is.
> It isn't checking the extend class hierarchy, but rather the implicit
> hierarchy of metaclass superclasses (the Classes themselves).
> As it turns,
> this is rooted at the class Class, so it responds true, but the
> classes are _not_ instances of class. They just happen to have the same
> format and shape that an instance of Class would have and it
> inherits all of
> the behavior of Class, since its class hierarchy is rooted at Class.
> So let me correct my description of the parallel hierarchies:
> metaclass inheritance (with what it is)
> Class (class Class)
> -> ProtoObject class (a Metaclass)
> -> Object class (a Metaclass)
> -> Morph class (a Metaclass)
> class inheritance (with what it is)
> Except for nil, this is an object that is shaped like a Class, but isn't.
> It acts like a Class because behavior is inherited from the metaclass
> inheritance, rooted at class Class.
> nil (UndefinedObject)
> -> ProtoObject (an object that is shaped like a Class)
> -> Object (an object that is shaped like a Class)
> -> Morph (an object that is shaped like a Class)
More information about the Squeak-dev