Use the ::CLASS directive to create a class. Programs can then use the new class by specifying it as a REXX environment symbol (the class name preceded by a period) in the program. For example, in A Sample Program Using Directives, the Savings class is created using the ::CLASS directive. Then a program uses the new class by specifying it as an environment symbol, ".savings".
The new class that you create acquires any methods defined by subsequent ::METHOD directives within the program, until either another ::CLASS directive or the end of the program is reached.
You can use the ::CLASS directive's SUBCLASS option to make the new class the subclass of another. In A Sample Program Using Directives, the Savings class is made a subclass of the Account class. A subclass inherits instance and class methods from its specified superclass; in the sample, Savings inherits from Account.
Additional ::CLASS directive options are available for:
When you create a new class, it is always a subclass of an existing class. If you do not specify the SUBCLASS or MIXINCLASS option on the ::CLASS directive, the superclass for the new class is the Object class, and it is not a mixin class.
Your class definition may be in a file of its own, with no executable code preceding it. This is often the case when you are defining classes and methods to be shared by several programs. You put the executable code in another file and refer to the class file using a ::REQUIRES directive.
REXX processes ::CLASS directives in the order they appear, unless there is a dependency on some later directive's processing. Two classes cannot be created having the same class name in one program. If multiple programs contain classes with duplicate names, the last ::CLASS directive processed will be used.