Reference variables

A parameter or variable is an area of storage. In some cases, the variable contains a value, for example, a particular name or employee ID. In other cases, the variable is a reference variable, and contains an address that holds the value at run time. Any variable based on a reference type is a reference variable. Reference types include the following:

The Exception Record stereotype is also defined as a reference type.

All variables that you base on these types are reference variables.

You cannot use a reference variable until you initialize it. A new reference variable has a null value by default, and causes a NullValueException when you use it to try to access a value, field, or function. Initialize a reference variable either with the new operator, or with a set-value block, which is somewhat more efficient (see Set-value blocks):
// new operator makes the variable non-null
myDictionary Dictionary = new Dictionary;

// so does an empty set-value block
myDictionary Dictionary{};

Array variables are also initially null, but you can initialize them by specifying a size. For more information, see Arrays.

Assignments and comparisons for reference variables follow different rules than those for value-based variables. For more information, see Reference compatibility in EGL.

Compatibility

Table 1. Compatibility considerations for reference variables
Platform Issue
COBOL generation Large object types BLOB and CLOB are not supported.
Java generation The following types are supported: ANY, BIGINT, BIN (but only in the absence of decimal places), Boolean, DataItem, DATE, DECIMAL, Delegate, Dictionary, FLOAT, INT, NUM, NUMBER, SMALLFLOAT, SMALLINT, STRING (but only in the absence of a size limit) , TIME, TIMESTAMP, NUM, MONEY, Service parts, Interface parts, External types (stereotype JavaScript), arrays of supported types, and non-structured Basic, Exception, and SQL Record parts.

The following types are not supported: ArrayDictionary, BIN (with decimal places), BLOB, CHAR, CLOB, DBCHAR, HEX, INTERVAL, MBCHAR, NUMC, STRING (with a size limit), PACF, UNICODE, and structured Record parts.

JSF You cannot pass a reference variable to the function specified by the onConstructionFunction property in a JSF handler; neither can you place a reference variable in (or retrieve a reference variable from) the session or request object.

Feedback