[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  Name conflicts

  As mentioned, repeated inheritance is handled by treating repeatedly
  inherited classes as a single class. This prevents any possibility of
  naming conflicts due to repeated inheritance. However, naming conflicts
  can still occur between classes.

  A naming conflict occurs when a message of the same name is inherited from
  two different branches of the hierarchy. When this occurs, the default
  behavior for the duplicate message will be determined by whichever class
  is first in the linearized superclass precedence list described earlier.
  In other words, one message will override the other.

  In such situations, it is usually necessary to be able to access both
  messages. One mechanism for doing this is the scope resolution message, of
  the form:

    obj:<className>:<message>

  to access the non-default message. For example, assuming a method
  show() was defined in TextWindow and BorderedWindow, and we wish to
  invoke the show() method from BorderedWindow, we would use:

    ::BorderedWindow:show()

  The default inheritance sequence can be overridden for specific messages,
  by including the appropriate statement in the class specification. For
  example, in the class BordTextWindow, we could include the following
  statement:

    MESSAGE show IN BorderedWindow

  This would cause BorderedWindow's show to be invoked by default when
  the show message is sent to an instance of BordTextWindow.

  You can also provide an alias for a message as follows:

    MESSAGE borderedShow IS show IN BorderedWindow

  This allows both show messages to be accessed without resorting to the
  use of a scope resolution message. Since a scope resolution message
  involves an extra message send, using message aliases is more efficient.

This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson