[self-interest] Interesting question on factoring/clone

Dru Nelson dru at redwoodsoft.com
Tue Sep 14 08:13:36 UTC 1999


I was talking to my associate on the list Steve at dekorte.com about some
Proto language topics.

I'm working on language implementation (like many on this list), but not
quite a 'Self'.

I often finding myself doing something that is considered the 'naive'
implementation (see Self Implementation - Smith, Ungar :-)

One question that I didn't really think about, and completely skipped over
was, how do you clone a typical proto with inheritance.

For example:

You have a proto: p

it has a parent pointing to some traits object called: PointObject

Now lets say I create a new point object called ColoredPointObject.
This would have methods for dealing with the color.

So now there is this proto: cp with one attribute: color.

Now cp has a parent set to p and a parent set to ColoredPointObject.

If I do a clone of cp, it will just clone the cp and it's attributes.
But what about the p proto that has actual x,y attributes. Shouldn't that
get cloned as well?

In the small tutorial online, the convention appears to be to get all of
your state in the proto and then inherit from relatively state free
traits. However in this example, that would mean changing what I have to
be a proto with the attributes: x, y, z and pointing to the ColoredPoint
proto (which would have a parent slot of PointObject)

This whole factoring thing was something that I completely overlooked in
my study of prototype based systems. 


Dru Nelson
San Mateo, California





More information about the Self-interest mailing list