[self-interest] Re: Interesting question on factoring/clone

Jecel Assumpcao Jr jecel at lsi.usp.br
Tue Sep 14 14:44:26 UTC 1999

Dru Nelson wrote:
> [interesting factoring example]

The way Self currently handles this is by using annotations to
create "copydown slots". This simply makes the process of
keeping the data slots in p and cp coherent automatic - if
you add some slot to p then the programming environment will
also add that slot to cp (same thing for deleting a slot).

You might find the NewtonScript way more interesting (see the
papers at http://www.best.com/~wsmith/works.html): each object
has exactly two parents, one from which it inherits its data
and another from which it inherits its behavior:

   _proto of cp : p
   _parent of cp : ColoredPoint
   _proto of p: ()
   _parent of p: ObjectPoint

Now suppose we "clone" cp to create acp. This starts out its
life as an otherwise empty object with cp as its data parent:

   _proto of acp: cp
   _parent of acp: ()

This still works ok, as long as acp has the same "color" value
as cp and the same "x" and "y" values as p. But if we send a
message to acp that would change one of those values, we create
a new slot on the fly in acp itself and change that slot instead
of the parent's slot (this is called "copy on write slots").

This is much more dynamic and flexible than Self, but also
very hard to get high performance with. While Self is optimized
for speed (no matter how much memory it takes), NewtonScript is
optimized for a small memory footprint (no matter how slow it
is) which is reasonable given that the first Newtons had a total
of 640KB of memory!

Depending on what you want to do, this could be an interesting

-- Jecel

More information about the Self-interest mailing list