Defining a New Class

To define a new class using messages, you send a SUBCLASS message to the new class's superclass. That is, send the message to the class that will be immediately above the new class in the hierarchy. So, to define a subclass of the Object class called Account, enter:

account = .object~subclass('Account')

Here, .object is a reference to the REXX Object class. .Object is an environment symbol indicating the intention to create a new class that is a subclass of the Object class. Environment symbols represent objects in a directory of public objects, called the Environment object. These public objects are available to all other objects, and include all the classes that REXX provides. Environment symbols begin with a period and are followed by the class name. Thus the Object class is represented by .object, the Alarm class by .alarm, the Array class by .array, and so on.

The "twiddle" (~) is the "message send" symbol, subclass is a method of Class, and the string identifier in parentheses is an argument of SUBCLASS that names the new class, Account.


[Back: Creating Classes Using Messages]
[Next: Adding a Method to a Class]