[self-interest] Issues about delegation

Jecel Assumpcao Jr jecel at merlintec.com
Wed Nov 5 17:51:51 UTC 2003


On Wednesday 05 November 2003 09:06, J. Baltasar GarcĂ­a Perez-Schofield 
wrote:
>          How can I solve this ?
>          Of course I can think of some work arounds, such as
> recreating the "name" atribute in Employee, or using a composition
> relation instead of the inheritance one, but I think this should be
> possible to be solved whithin inheritance/delegation.

In one kind of prototype based language, such as Io (I think) or 
NewtonScript, you can create local copies of an inherited slot whenever 
you try to change its value. These "copy-on-write" slots are really 
nice when they do what you want since they avoid replicating shared 
state.

Self is a bit more conservative so you have to explicitly recreate any 
slots you want a local copy of. The language doesn't have any built in 
feature to help you with that, but the programming environment does 
(see "copy-down slots" in the manuals). The most interesting papers for 
you might be:

http://research.sun.com/self/papers/organizing-programs.html

and

http://research.sun.com/self/papers/parents-shared-parts.html

Here is one possible organization of your application in Self -

     traits person = ( | parent* = traits clonable.
                         otherStuff....
     | )

     person = ( | parent* = traits person.
                  name <- 'John Doe'
     | )

     traits employee = ( | parent* = traits person.
                           moreStuff....
     | )

     employee = ( | parent* = traits employee.
                    name <- 'Jane Doe'.
                    number <- 432
     | )

which looks pretty similar to what it would be in a class based 
language, with the additional complication of having to repeat the 
'name' slot manually (using proper syntax and copy-downs would make 
this look far too complicated - it is actually simple in the graphical 
user interface).

-- Jecel



More information about the Self-interest mailing list