Skip to main content

Software > Software Development > IBM REXX Family >

NetRexx

Technical detail

Properties instruction

properties [visibility] [modifier];
where visibility is one of:
     inheritable
private
public

   and modifier is one of:

     constant
static
volatile

   and there must be at least one visibility or modifier keyword.

The properties instruction is used to define the attributes of following property variables, and therefore must precede the first method instruction in a class. A properties instruction replaces any previous properties instruction (that is, the attributes specified on properties instructions are not cumulative).

The visibility and modifier keywords may be in any order.

An example of the use of properties instructions may be found in the Program Structure section.

Visibility

Properties may be public, inheritable, or private:

  • A public property is visible to (that is, may be used by) all other classes to which the current class is visible.
  • An inheritable property is visible to (that is, may be used by) all classes in the same package and also those classes that extend (that is, are subclasses of) the current class, and which qualify the property using an object of the subclass, or either this or super.
  • A private property is visible only within the current class.

By default, if no properties instruction is used, or visibility is not specified, properties are inheritable (but not public).[1] 

Modifier

Properties may also be constant, static, or volatile:

  • A constant property is associated with the class, rather than with an instance of the class (an object). It is initialized when the class is loaded and may not be changed thereafter.
  • A static property is associated with the class, rather than with an instance of the class (an object). It is initialized when the class is loaded, and may be changed thereafter.
  • A volatile property may change asynchronously, outside the control of the class, even when no method in the class is being executed. If an implementation does not allow asynchronous modification of properties, it should ignore this keyword.

Constant and static properties exist from when the class is first loaded (used), even if no object is constructed by the class, and there will only be one copy of each property. Other properties are constructed and initialized only when an object is constructed by the class; each object then has its own copy of such properties.

By default, if no properties instruction is used, or modifier is not specified, properties are associated with an object constructed by the class, and are neither constant nor volatile.

Properties in interface classes

In interface classes, properties must be both public and constant. In such classes, these attributes for properties are the default and the properties instruction must not be used.

Footnotes:

[1]  The default, here, was chosen to encourage the 'encapsulation' of data within classes.

 

 

PreviousTable of contents Next
We're here to help
Easy ways to get the answers you need.
E-mail us

or call us at
877-426-3774
Priority code:
104CBW67