Skip to Content Java Solaris Communities Partners My Sun Sun Store United States Worldwide

»  Spotlight Articles
»  Projects
»  Publications
»  People
»  Awards
»  Events
»  Downloads
»  Internships
»  Contrarian Minds
»  About Sun Labs

Copy-downs

Used to propagate structure from one prototype to another:


Copied slots are shown in pink.

  • Need to specify:
    • copy-down parent
    • selector to use to make copy
    • slots to omit (optional)


  • Programming environment propagates changes to copied-down descendants
  • Copy-downs

    Because Self eschews classes, it is necessary to copy down slots when refining an object. For example, the prototypical dictionary object is derived from the prototypical set, and contains many slots that were prescribed by the implementation of set. Some mechanism is needed to ensure that the relationship between the two objects is maintained, should set be changed.

    In a class-based language, this need is met by a rule ensuring that subclasses include any instance variables defined in their superclasses. In Self, this inheritance of structure is separated from the inheritance of information performed by the normal hierarchy of parent slots.

    Instead of including in the language a facility for inheriting structure, Self 4.0 implements a facility in the environment, called "copy-down." An object's annotation can contain a copy-down parent, copy-down selector, and set of slots to omit. The copy-down parent is sent the message given by the copy-down selector, and (except for the slots-to-omit), the slots in the result are added to the object. Copied-down slots are shown in pink.

    In creating dictionary from set, the slots parent and prototype were omitted because their contents had to be different; copied-down slots are copied, they cannot be specially initialized in Self 4.0. It is also possible to omit a slot because it is simply not needed; most other object-oriented programming systems would not allow a subclass to avoid inheriting an instance variable.

    The Self 4.0 programming environment uses the copy-down information to allow the programmer to use a classical style when appropriate. For example, if the programmer adds a slot to set, the environment will offer to add it to dictionary, too.

    The least convenient aspect of using copy-downs is that to do the moral equivalent of creating a subclass, the programmer has to create two objects: a new traits object, and a new prototype, and then specify that the new prototype is to be copied down.

    [ Previous ] [ Index ] [ Next ]
    Would you recommend this Sun site to a friend or colleague?
    Contact About Sun News Employment Privacy Terms of Use Trademarks Copyright 1994-2008 Sun Microsystems, Inc.