The NetRexx language introduced the ability to index array-like objects with square brackets.
roo! also uses square brackets to reference composite object values.
Indexing within roo! programs is somewhat similar, but may differ from the NetRexx technique.
Unlike NetRexx, indexing within roo! programs uses an approach which is more similar to that used in C, C++, Java, or C# programs.
For example, roo! programs can use nested and cascading index references.
Arbitrary composite items can be indexed with square brackets.
Square brackets can be used to reference or revise classes that are derived from the aggregate built-in class.
The expression
can be used wherever a term is expected in a Rexx expression.
This reference is a shorthand equivalent to:
obj ~ getAt( indexValue )
If the item which precedes the left square bracket is not an instance, the reference is transformed into a compound symbol reference instead.
This emulates a NetRexx indexed string reference, with one index value.
In this case, the reference is similar to:
value(
indexValue may be a compound variable.
obj ~ setAt( indexValue, newValue )
call value
indexValue may be a compound variable.
The instruction is actually equivalent to the result of the following value built-in function request:
Where:
Observe: if the compound variable is not assigned a value, the value of simple symbol obj becomes the value of the reference.
This differs from the normal Rexx value that is substituted for an unassigned compound variable.
Similarly, square brackets can be used within the value that precedes an assignment expression (=).
The expression
is a shorthand equivalent to:
If the item which precedes the left square bracket is not an instance, the reference is transformed into a compound symbol reference instead.
In this case, the instruction is similar to:
The instruction is actually equivalent to:
Where:
Note: recognition of an assignment instruction is enhanced to search for the equal sign that follows a bracketed reference.
The expression on the left side of the equal sign can have a cascade of square bracket expressions as well.
Note: array references can be nested, for example:
Note: array references can be performed in sequence, for example:
Note: the expression within the square brackets is evaluated as though the square brackets were parentheses.