|
|
|
|
|
by bhk
3312 days ago
|
|
Can we ever get away from the misnomer of "prototype-based OO"? In Self we have two ways of specialization: 1. Prototypes
2. Parents
Prototypes are objects that are "cloned" to create instances, a very simple and direct notion of inheritance. We create an object (a "prototype") with properties that apply to a larger set of objects, and then for each instance we copy (clone) it and then add or modify properties as necessary for the instance. Self had optimizations to deal with this so instances did not end up being very fat.Parents are objects that other objects "inherit from". At run-time property lookups are delegated to a parent. The difference between a parent and a prototype is that changes to the prototype do NOT affect the derived instances. Changes to a parent DO affect the derived instances. So, when I read about "class-based" versus "prototype-based" languages, I cringe. It is really "class-based" versus "parent-based". How did cloning get confused with run-time delegation? Self introduced the notion of self-describing instances. That is the essential coolness. The simplifying notion. http://www.selflanguage.org/_static/published/self-power.pdf |
|