resend (was: Multiple inheritance)

Jecel Assumpcao Jr jecel at
Mon Nov 7 14:12:36 UTC 2005

J. Baltasar Garcia Perez-Schofield wrote:
> > [Self has always had two kinds of resends]
> 	So if a "resend" is performed, and all parents are searched ... is a
> depth lookup run or not ? Maybe a lookup in width ?

Imagine we have an object like

( | parent* = traits clonable.
     sharedStuff* = mixins utilities. "just an example - not in Self
     moreStuff* = mixins graphics. "another example"
     subElements <- list copyRemoveAll.
     copy = ( | new |
                    new: resend.copy.
                    new subElements: subElements copy.
                    new ).
| )

The "resend.copy" will do exactly the same (full) search that just
"copy" would have done except it will skip the local methods in the
object, which in this case is the very method doing the resend. That
means that any copy slots in "parent", "sharedStuff" and "moreStuff"
will be found and if there is more than one then a debugger will pop up.
Note that when I say a full search I don't mean that when a slot is
found in an object we keep going through its parents anyway, but that it
isn't a depth first search that would stop if the slot is found in
"sharedStuff" and wouldn't look in "moreStuff".

An alternative would be to replace "resend.copy" with "parent.copy" (for
example) and in that case a "copy" slot in either "sharedStuff" or in
"moreStuff" would not cause a problem. This is what Ian was talking
about when he said "name clashes can be resolved manually by specifying
the path".

Some people prefer a depth first search but that has a nasty side effect
that just changing the order of "sharedStuff" and "moreStuff" in the
above code could change its meaning! The way Self currently does things
allows you to not worry about this kind of thing.

-- Jecel

More information about the Self-interest mailing list