Inheritance
|
InheritanceAs 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.
|