Hooks, aspect-oriented programming, and design by contract

James_Althoff at i2.com James_Althoff at i2.com
Mon Jan 28 19:35:15 EST 2002


[Alex Martelli]
>In Smalltalk, metaclasses are instances of Metaclass.  Each metaclass
>is the metaclass of a single class.

[Jim]
> Although the latter is by convention and not a restriction of the
> language.

[Alex]
>Thanks for clarifying this -- I thought it was a language rule, not
>just a convention (shows you how long it is since I last dabbed in
>ST and how superficial was my dabbling, I guess).  Now I'm trying
>to figure out in what cases I could violate the convention, how, and
>with what effects (can you suggest a URL -- this seems OT here
>in c.l.p)...

It sounds to me like you must have done a reasonable amount of
non-superficial dabbling to have gotten such a good handle on the metaclass
stuff!

Anyway, the main place (usually the only place, actually) in a standard
Smalltalk system where you would have class objects that are all instances
of the same metaclass is the one that you pointed out above -- namely,
every metaclass object is an instance of the same class: Metaclass (well,
except for Metaclass itself which is an instance of Metaclass.
__metaclass__:-).  What this means is that all metaclass objects share the
same methods (those defined in class Metaclass).  In practice, application
classes that you would create using the Smalltalk IDE or by writing code
(by invoking a class creation method on class Class) will each have their
own metaclass because the class creation code in class Class does that by
default.

If you want to do fun and esoteric experimentation, you might want to check
out the Squeak implementation of Smalltalk.  This implementation is open
source and is being done under the direction of Alan Kay, Dan Ingalls, and
others from the original Smalltalk team (originally at Xerox PARC, then at
Apple, then at Disney, now on their own).  Essentially all of Squeak
Smalltalk is written in Smalltalk -- including the virtual machine -- so
you can really go wild trying out different stuff.  You can find out more
and get downloads from: http://www.squeak.org if you are interested.  :-)

Jim





More information about the Python-list mailing list