The Class Class

The Class class is used for generating new classes. If a class is like a factory for producing instances, Class is like a factory for producing factories. Class is the parent of every new class in the hierarchy, and these all inherit Class-like characteristics. Class-like characteristics are methods and related variables, which reside in Class, to be used by all classes.

The class Class subclasses (specializes) The Object Class .

A class that can be used to create another class is called a metaclass ( Metaclasses ). The Class class is unique among Rexx classes in that it is the only metaclass that Rexx provides. As such, the Class's methods not only make new classes, they make methods for use by the new class and its instances. They also make methods that only the new class itself can use, but not its instances. These are called class methods. They give a new class some power that is denied to its instances.

Because each instance of Class is another class, that class inherits the Class's instance methods as class methods. Thus if Class generates a Pizza factory instance, the factory-running actions (Class's instance methods) become the class methods of the Pizza factory. Factory operations are class methods, and any new methods created to manipulate pizzas would be instance methods.


How Subclasses Inherit Instance Methods from the Class Class

As a programmer, you typically create classes by using directives, rather than the methods of the Class class. In particular, you'll use the ::CLASS directive, described later in this section. The ::CLASS directive is a kind of Rexx clause that declares class definitions in a simple, static form in your programs.