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

Inheritance

  • Parent slots implement object-based inheritance by extending message lookup to other objects.

  • A parent slot is a kind of data slot, designated by a trailing *.

  • If no slot matching a message is found in the local object, the search continues in the parent, and the parent©s parent, etc.

Inheritance

As we have described lookup so far, a message must match one of the receiver's slots. If not, an error will result, and a debugger will appear.

Inheritance modifies the lookup procedure by extending the search to other objects. These objects are located via parent slots, which are a special kind of data slot. Any data slot can be designated a parent, by attaching an asterisk to the slot name.

If a message is sent to an object with a parent slot, then the search for a matching slot is extended to the parent if no slot is found within the object.

If the search locates a method, then the method is executed in the context of the receiver of the message (i.e., self is bound to the receiver of the message, not the object in which the method was found).

By this simple device, inheritance has been liberated from the domain of classes and made available to all objects. We can, if we so choose, make object structures that mimic the conventional class-instance relationship, but we are no longer forced to do so.

Terminology: we use the terms parent, child, ancestor and descendant in ways analogous to their usual meaning.

[ 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.