Protypes and Self and Squeak (was RE: Browsers)

Stefan Matthias Aust sma at mail.netsurf.de
Fri Mar 19 21:33:24 UTC 1999


>I would like to know how prototypes delegate to
>'super'. Do they have a reference to the
>object they were cloned from like self prototypes (parent?).

If you refer to hmm's ProtoObject implementation, AFAIK this can't be done
at all. Here, all proto objects have a ProtoBehavior instance as a class
which has Object as superclass. Other ways of inheritance is not supported.

If you want to know, how it could be done, well, the Self way is to mark
one or more slots as so called parent slots.  When the VM is looking for a
method, it will first search the current receiver and then all objects
stored in parent slots, depth-first, in the order the slots where added.
That method is then called in the context of the original behavior.  This
can't be done with the current VM without sacrifying a lot of runtime.

However, it can be added fairly easy and I already tried to add a new
primitive (as this was easier than to invent a new byte code instruction
and probably not slower) to the interpreter simulator to allow a similar
kind of method lookup. With my example, the behavior instance (aka the
receiver's class) has an additional arry of parent objects, which are
searched as described.


bye
--
Stefan Matthias Aust  //  ...and now something completely different





More information about the Squeak-dev mailing list