Steve Dekorte wrote:
Is there any interest in making Squeak prototype-based?
Well, I am working on this. -- Jecel
What are prototypes and how would they be used in Squeak?
Thank You,
John-Reed Maffeo
What are prototypes and how would they be used in Squeak?
In Smalltalk, every object has a class that describes the structure and behavior of this instance. For example, the class Point describes how point object objects are added, compared or asked for their x or y coordinate. The Point class also holds the information, that every new point has two instance variables called x and y that will store the point's coordinate.
Classes are also used to create new objects (so called instances) based on these information. You can see them as a blue print (or a factory) for new obejcts.
In a prototype based language, there are no classes. All objects know theirself how to behave. Each object is unique and independent of all other objects.
But there has to be some way to create new objects, even without classes. You simply take another object and make a copy of it (a so called clone). These template objects are called prototypes, as they're acting as a common instance of that kind of objects.
But is this really useful? It depends. Sometimes, you're dealing with a lot of objects which are all different. Look for example at a user interface. Each button has a special task to fulfill, each input field holds a different text. Every new menu is very special. One solution might be to create a class for each special object and make exactly one instance. But using prototypes you can customize - without bothering about classes is much easier.
Generally, prototype-based languages are more direct and easier to understand because they lack the meta object layer. And with prototypes, you can easily emulate classes. The other way round is also possible but more difficult.
bye -- Stefan Matthias Aust // Ride on - through the night - ride on
My OOPSLA CD-ROM is at home, but I recall Henry Lieberman had a paper in the 1986 conference illustrating what can be done using prototypes that cannot be done as well using classes. If I recall correctly again, this led to debates and ultimatelyf (was it OOPSLA 1987?) something called the Treaty or Orlando (the site of OOPSLA that year) which lays out the relationship between classes and prototypes, at least at that time.
Technically, the issue wasn't classes vs. prototypes, but it was inheritance vs. delegation. But it hits the same mark, eh?
squeak-dev@lists.squeakfoundation.org