Skip to main content

Software > Software Development > IBM REXX Family >

NetRexx

Technical detail

Types and Classes

Programs written in the NetRexx language manipulate values, such as names, numbers, and other representations of data. All such values have an associated type (also known as a signature).

The type of a value is a descriptor which identifies the nature of the value and the operations that may be carried out on that value.

A type is normally defined by a class, which is a named collection of values (called properties) and procedures (called methods) for carrying out operations on the properties.

For example, a character string in NetRexx is usually of type Rexx, which will be implemented by the class called Rexx. The class Rexx defines the properties of the string (a sequence of characters) and the methods that work on strings. This type of string may be the subject of arithmetic operations as well as more conventional string operations such as concatenation, and so the methods implement string arithmetic as well as other string operations.

The names of types can further be qualified by the name of a package where the class is held. See the package instruction for details of packages; in summary, a package name is a sequence of one or more non-numeric symbols, separated by periods. Thus, if the Rexx class was part of the netrexx.lang package,[1]  then its qualified type would be netrexx.lang.Rexx.

In general, only the class name need be specified to refer to a type. However, if a class of the same name exists in more than one known (imported) package, then the name should be qualified by the package name. That is, if the use of just the class name does not uniquely identify the class then the reference is ambiguous and an error is reported.

Primitive types

Implementations may optionally provide primitive types for efficiency. Primitive types are 'built-in' types that are not necessarily implemented as classes. They typically represent concepts native to the underlying environment (such as 32-bit binary integer numbers) and may exhibit semantics that are different from other types. NetRexx, however, makes no syntax distinction in the names of primitive types, and assumes binary constructors exist for primitive values.

Primitive types are necessary when performance is an overriding consideration, and so this definition will assume that primitive types corresponding to the common binary number formats are available and will describe how they differ from other types, where appropriate.

In the reference implementation, the names of the primitive types are:
  boolean
char
byte
short
int
long
float
double
where the first two describe a single-bit value and Unicode character respectively, and the remainder describe signed numbers of various formats. The main difference between these and other types is that the primitive types are not a subclass of Object, so they cannot be assigned to a variable of type Object or passed to methods 'by reference'. To use them in this way, an object must be created to 'wrap' them; Java provides classes for this (for example, the class Long).

Dimensioned types

Another feature that is provided for efficiency is the concept of dimensioned types, which are types (normal or primitive) that have an associated dimension (in the sense of the dimensions of an array). Dimensioned values are described in detail in the section on Arrays.

The dimension of a dimensioned type is represented in NetRexx programs by square brackets enclosing zero or more commas, where the dimension is given by the number of commas, plus one. A dimensioned type is distinct from the type of the same name but with no dimensions.

Examples:

  Rexx
int
Rexx[]
int[,,]

The examples show a normal type, a primitive type, and a dimensioned version of each (of dimension 1 and 3 respectively). The latter type would result from constructing an array thus:

  myarray=int[10,10,10]

That is, the dimension of the type matches the count of indexes defined for the array.

Footnotes:

[1]  This is in fact where it may be found in the reference implementation.

 

 

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