[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
MESSAGE...IS
Synopsis
Define alternate name for inherited message
Syntax
MESSAGE <message name> IS <original name>
Arguments
<message name> is the name of the message being declared.
<original name> is the name of an inherited message (a message
defined in an ancestor class) which the declared message will be
mapped to.
Description
This command allows an alternative name to be defined for an
existing message. The existing message must be defined in an
ancestor class of the class being created. The command allows a
class to be tailored so that its message names match its behavior.
One common way in which this command is used is to declare
messages as deferred or null using a statement of the
following form:
MESSAGE <name> IS [DEFERRED | NULL]
This has the effect of mapping the specified message onto a
predefined method in the Class(y) system class, Object. See the
sections on Deferred Methods and Null Methods for more
information.
Example
Assume that a Vehicle class defines the message width. We
would like to define a subclass of Vehicle, called Boat. However,
the width of a boat at its widest point is usually referred to as
its beam. We could handle this by writing a method in the Boat
class:
METHOD beam
RETURN ::width
The MESSAGE...IS command provides us with a more efficient
shorthand for doing this in the class specification, as follows:
CREATE CLASS Boat FROM Vehicle
// ...
MESSAGE beam IS width
This achieves the same effect, without the need for a method, and
will provide better performance.
Note
The MESSAGE...IS command can only be used to define an
alternative name for a message in an ancestor class. To define an
alternative name for a method in the current class, use the
MESSAGE...METHOD command. Currently, an alternative name for a
variable in the current class cannot be defined directly.
See Also
VAR...IS, Deferred Methods, Null Methods
See Also:
VAR...IS
Deferred Methods
Null Methods
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson