Prototypes

Ralph E. Johnson johnson at cs.uiuc.edu
Tue Mar 3 20:45:11 UTC 1998


I would like to throw some cold water on this love-fest.  I've
been following the class vs. prototypes discussion since 1987.
I've built a prototype based application (in Smalltalk, of course).
In my opinion, "the emperor has no clothes".  Anything you can do
in a prototype language, you can do in Smalltalk just as easily.
It would be a waste of time to restructure the VM to be based on
prototypes.  

I agree that it is often useful for a programming environment to
prototype-based.  But this does not require the language to be
based on prototypes.  Bob Hinkle wrote the "Object Inspector" that
lets you place breakpoints on a single object.  He provided library
support that lets you give any object its own method dictionary so
you can hack on it without affecting any other objects.  He has a
subclass of Behavior called "LightweightClass" and there is a method
that makes an object replace its class with a LightweightClass that
is a subclass of its old class.  Then you can add methods to its
class without affecting any other object.  We used it in a Hypercard
clone to add behavior to buttons, and in a Alternate Reality Kit clone
to add behavior to objects.  Plus, Accounts was based on prototypes,
but entirely at the application programming level, without any 
meta programming support.

BTW, the one VM hack that is useful in LightweightClass is the
ability to set the class of an object.  You can get around this
by making a shallow copy of the object, but with the new class,
and then having the old copy "become" the new one.

-Ralph





More information about the Squeak-dev mailing list