Product Site

1.13.5.1. Evaluated Compound Variables

The value of a stem variable is always a Stem object (see Section 5.3.16, “Stem Class” for details). A Stem object is a type of collection that supports the [] and []= methods used by other collection classes. The [] method provides an alternate means of accessing compound variables that also allows embedded subexpressions.

Tails for compound variables are normally specified by symbols separated by periods. An alternative is to specify the tail as a bracketed list of expressions separated by commas. The expressions are evaluated to character strings. These are concatenated with intervening periods and the resulting string is used as tail. This notation can be used in assignments to compound variables as well as when referencing them. Examples:
Example 1.32. Evaluated compound variables
a.[1+2,3+4]=17      -- assigns A.3.7
Say a.3.7           -- => 17
v1='1+2'
v2='3+4'
a.v1.v2=18          -- tail used: '1+2.3+4'
Say a.['1+2','3+4'] -- => 18
Parse Value '1 2 3' With . a.[1,1+1] .
Say a.1.2           -- => 2