• Indexed references

    1.  The NetRexx language introduced the ability to index array-like objects with square brackets.

    2.  roo!™ also uses square brackets to reference composite object values.

    3.  Indexing within roo!™ programs is somewhat similar, but may differ from the NetRexx technique.

    4.  Unlike NetRexx, indexing within roo!™ programs uses an approach which is more similar to that used in C, C++, Java, or C# programs.

    5.  For example, roo!™ programs can use nested and cascading index references.

    6.  Arbitrary composite items can be indexed with square brackets.


    7.  Square brackets can be used to reference or revise classes that are derived from the aggregate built-in class.

    8.  The expression

            obj [ indexValue ]

    9.  can be used wherever a term is expected in a Rexx expression.

    10.  This reference is a shorthand equivalent to:

            obj ~ getAt( indexValue )


    11.  If the item which precedes the left square bracket is not an instance, the reference is transformed into a compound symbol reference instead.

    12.  This emulates a NetRexx indexed string reference, with one index value.

    13.  In this case, the reference is similar to:

            obj.indexValue

    14.  The instruction is actually equivalent to the result of the following value built-in function request:

            value( 'OBJ.' || indexValue, newValue )

    15.  Where:

            indexValue may be a compound variable.

    16.  Observe: if the compound variable is not assigned a value, the value of simple symbol obj becomes the value of the reference.

    17.  This differs from the normal Rexx value that is substituted for an unassigned compound variable.


    18.  Similarly, square brackets can be used within the value that precedes an assignment expression (=).

    19.  The expression

            obj [ indexValue ] = newValue

    20.  is a shorthand equivalent to:

            obj ~ setAt( indexValue, newValue )

    21.  If the item which precedes the left square bracket is not an instance, the reference is transformed into a compound symbol reference instead.

    22.  In this case, the instruction is similar to:

            obj.indexValue = newValue

    23.  The instruction is actually equivalent to:

            call value 'OBJ.' || indexValue, newValue

    24.  Where:

            indexValue may be a compound variable.

    25.  Note: recognition of an assignment instruction is enhanced to search for the equal sign that follows a bracketed reference.

    26.  The expression on the left side of the equal sign can have a cascade of square bracket expressions as well.


    27.  Note: array references can be nested, for example:

            obj [ obj2[ indexValue ] ]

    28.  Note: array references can be performed in sequence, for example:

            obj [ indexValue1 ] [ indexValue2 ]

    29.  Note: the expression within the square brackets is evaluated as though the square brackets were parentheses.