[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
VAR...IS
Synopsis
Define alternate name for inherited variable
Syntax
VAR <variable name> IS <original name>
Arguments
<variable name> is the alternative name that the inherited
variable will be given in the current class
<original name> is the name of an inherited variable (a
variable defined in an ancestor class) which the declared
alternative name will be mapped to.
Description
This command allows an alternative name to be defined for an
existing variable. The existing variable 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.
Example
Assume that a Vehicle class defines a variable called 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
This handles access to the width variable via the beam
message. As discussed under the MESSAGE...IS command, this
could be done more efficiently in the class specification as
follows:
MESSAGE beam IS width
However, neither of these solutions handles assignment via the
beam message. To support assignment statements of the form:
oBoat:beam := x
we can use the VAR...IS command in the class specification as
follows:
CREATE CLASS Boat FROM Vehicle
// ...
VAR beam IS width
This will allow both access and assignment to the width
variable via the beam message.
Note
The VAR...IS command can only be used to define an alternative
name for a variable in an ancestor class. Currently, an
alternative name for a variable in the current class cannot be
defined directly. A method can be defined to do this if necessary.
See Also
MESSAGE...IS
See Also:
MESSAGE...IS
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson