Getting rid of metaclasses (Was: Behaviors vs Modules)

Dan Ingalls Dan at SqueakLand.org
Sun Feb 24 23:10:21 UTC 2002


>I was leaning towards getting rid of metaclasses.  A class reference
>like "String" would instead reference the String prototype, and class
>methods would be moved to instance methods under an appropriate category
>like "instance creation".  Class variables can be replaced by instance
>methods that store arbitrary constants, instead of just literals.  This
>allows overriding without the need to use class instance variables.  And
>the prototype can serve as an example (enhancing documentation) or as a
>real prototype to copy.  The prototype (or any instance) would respond
>to #new the same as today by creating a brand new instance.  It would
>respond to #copy by copying itself.  So the user has a choice.

I think this is one of the "sweet spots" to aim for in a variant of Smalltalk.  For at least a year in the early history of Squeak, John Maloney and I were "just about" to do exactly what you propose, namely get rid of metaclasses and instantiate from prototypes.  It simplifies the model, keeps the benefits of class organization, and makes things "feel" more object-oriented.

The one other thing we were going to include is the ability to refine behavior starting with the object rather than its class, as in

	make me respond to <method description>
or
	make a copy that responds to <method description>

This just takes a couple of methods and completes the model for working with objects, without departing from Smalltalk's semantics and organization by classes.

Yeah.  Do it.

	- Dan



More information about the Squeak-dev mailing list