Previous

#### 5.3. Units associated with stowed values

{In Flanders fields the poppies blow Between the crosses, row on row, In Flanders Fields, John McCrae.}
{The fields of structured values may be obtained by selections {5.3.1 } and the elements of multiple values by slices {5.3.2 }; the corresponding effects on stowed names are defined also.}
##### 5.3.1. Selections
{A selection selects a field from a structured value or (if it is a "multiple selection") it selects a multiple value from a multiple value whose elements are structured values. For example, re OF z selects the first real field (usually termed the real part) of the yield of z. If z yields a name, then re OF z also yields a name, but if g yields a complex value, then re OF g yields a real value, not a name referring to one.}
###### 5.3.1.1. Syntax
A) REFETY :: REF to ; EMPTY.

B) REFLEXETY :: REF to ; REF to flexible ; EMPTY. {REF :: reference ; transient reference.}

a) REFETY MODE1 NEST selection{5C } : MODE1 field FIELDS applied field selector with TAG{48d } , of {94f } token, weak REFETY structured with FIELDS mode NEST SECONDARY{5C } ; where (MODE1) is (ROWS of MODE2), MODE2 field FIELDS applied field selector with TAG{48d } , of{94f } token, weak REFLEXETY ROWS of structured with FIELDS mode NEST SECONDARY{5C } , where (REFETY) is derived from (REFLEXETY){b,c,-}.

b) WHETHER (transient reference to) is derived from (REF to flexible){a,532a ,66a} : WHETHER true.

c) WHETHER (REFETY) is derived from (REFETY){a,532a ,66a} : WHETHER true. {Examples:

}

a)
re OF z ·re OF z1
{The mode of re OF z begins with 'reference to' because that of z does. Example:
INT age := 7; STRUCT(BOOL sex, INT age) jill; age OF jill := age; Note that the destination age OF jill yields a name because jill yields one. After the identity-declaration

STRUCT(BOOL sex, INT age) jack = (TRUE, 9), age OF jack cannot be assigned to since jack is not a variable.}

###### 5.3.1.2. Semantics
The yield W of a selection S is determined as follows:

· let V be the yield of the SECONDARY of S;

· it is required that V {if it is a name} be not nil;

· W is the value selected in {2.1.3.3.a, e , 2.1.3.4.k} or the name generated from {2.1.3.4.l } V by the field-selector of S.

{A selection in a name referring to a structured value yields an existing subname {2.1.3.3.e } of that name. The name generated from a name referring to a multiple value, by way of a selection with a ROWS-of-MODE-SECONDARY (as in re OF z1), is a name which may or may not be newly created for the purpose.}

##### 5.3.2. Slices
{Slices are obtained by subscripting, e.g., x1 [i], by trimming, e.g., x1 [2: n] or by both, e.g., x2 [ j : n, j] or x2 [,k]. Subscripting and trimming may be done only to PRIMARYs, e.g., x1 or (p | x1 | y1) but not re OF z1. The value of a slice may be either one element of the yield of its PRIMARY or a subset of the elements; e.g., x1 [i] is a real number from the row of real numbers x1, x2 [i, ] is the i-th row of the matrix x2 and x2 [ ,k] is its k-th column.}
###### 5.3.2.1. Syntax
A) ROWSETY :: ROWS ; EMPTY.

a) REFETY MODE1 NEST slice{5D } : weak REFLEXETY ROWS1 of MODE1 NEST PRIMARY{5D } , ROWS1 leaving EMPTY NEST indexer{b,c,-} STYLE bracket, where (REFETY) is derived from (REFLEXETY){531b,c ,-}; where (MODE1) is (ROWS2 of MODE2), weak REFLEXETY ROWS1 of MODE2 NEST PRIMARY{5D } , ROWS1 leaving ROWS2 NEST indexer{b,d,-} STYLE bracket, where (REFETY) is derived from (REFLEXETY){531b,c ,-}.

{ROWS :: row ; ROWS row.}

b) row ROWS leaving ROWSETY1 ROWSETY2 NEST indexer{a,b} : row leaving ROWSETY1 NEST indexer{c,d,-}, and also{94f } token, ROWS leaving ROWSETY2 NEST indexer{b,c,d,-}.

c) row leaving EMPTY NEST indexer{a,b} : NEST subscript{e}.

d) row leaving row NEST indexer{a,b} : NEST trimmer{f}; NEST revised lower bound{g} option.

e) NEST subscript{c} : meek integral NEST unit{32d } .

f) NEST trimmer{d} : NEST lower bound{46m } option, up to{94f } token, NEST upper bound{46n} option, NEST revised lower bound{g} option.

g) NEST revised lower bound{d,f} : at{94f } token, NEST lower bound{46m } .

h) *trimscript : NEST subscript{e}; NEST trimmer{f}; NEST revised lower bound{g} option.

i) *indexer : ROWS leaving ROWSETY NEST indexer{b,c,d}.

j) *boundscript : NEST subscript{e}; NEST lower bound{46m } ; NEST upper bound{46n } ; NEST revised lower bound{g}. {Examples:

}

a)
x2[i,j] ·x2[,j]
b)
1: 2, j (in x2 [1: 2,j]) ·i, j (in x2 [i,j])
c)
j (in x2 [1: 2,j])
d)
1: 2 ·@0 (in x1 [@0])
e)
j
f)
1: 2@0
g)
@0
{A subscript decreases the number of dimensions by one, but a trimmer leaves it unchanged. In rule a, 'ROWS1' reflects the number of trimscripts in the slice, and 'ROWS2' the number of these which are trimmers or revised-lower-bound-options. If the value to be sliced is a name, then the yield of the slice is also a name. Moreover, if the mode of the former name is 'reference to flexible ROWS1 of MODE', then that yield is a transient name (see 2.1.3.6.c ).}
###### 5.3.2.2. Semantics
a) The yield W of a slice S is determined as follows:

· let V and (I1, ... , In) be the {collateral} yields of the PRIMARY of S and of the indexer {b}of S;

· it is required that V {if it is a name} be not nil;

· let ((r1, s1), ..., (rn, sn)) be the descriptor of V or of the value referred to by V; For i = 1, ..., n,

Case A: Ii is an integer:

· it is required that ri <= Ii <= si;

Case B: Ii is some triplet (l, u, l'):

· let L be ri, if l is absent, and be l otherwise;

· let U be si, if u is absent, and be u otherwise;

· it is required that ri <= L and U <= si;

· let D be 0 if l' is absent, and be L - l¢ otherwise; {D is the amount to be subtracted from L in order to get the revised lower bound;}

· Ii is replaced by (L, U, D);

· W is the value selected in {2.1.3.4.a, g, i } or the name generated from {2.1.3.4.j} V by I1, ... , In.

b) The yield of an indexer I of a slice S is a trim {2.1.3.4.h } or an index {2.1.3.4.a} I1, ... , In determined as follows:

· the constituent boundscripts of S are elaborated collaterally; For i = 1... n, where n is the number of constituent trimscripts of S,

Case A: the i-th trimscript is a subscript:

· Ii is {the integer which is} the yield of that subscript;

Case B: the i-th trimscript is a trimmer T:

· Ii is the triplet (l, u, l'), where

· l is the yield of the constituent lower-bound, if any, of T, and is absent, otherwise,

· u is the yield of the constituent upper-bound, if any, of T, and is absent, otherwise,

· l' is the yield of the constituent revised-lower-bound, if any, of T, and is 1, otherwise;

Case C: the i-th trimscript is a revised-lower-bound-option N:

· Ii is the triplet (absent, absent, l'), where

· l' is the yield of the revised-lower-bound, if any, of N, and is absent otherwise. {Observe that, if (I1, ... , In) contains no triplets, it is an index, and selects one element; otherwise, it is a trim, and selects a subset of the elements.}

{A slice from a name referring to a multiple value yields an existing subname {2.1.3.4.j } of that name if all the constituent trimscripts of that slice are subscripts. Otherwise, it yields a generated name which may or may not be newly created for the purpose. Hence, the yield of x1 [1 : 2] :=: x1 [1 : 2] is not defined, although x1 [1] :=: x1 [1] must always yield true.}

{The various possible bounds in the yield of a slice are illustrated by the following examples, for each of which the descriptor of the value referred to by the yield is shown:

[0:9,2: 11] INT i3; i3 [1,3: 10 @3] ¢ ((3, 10)) ¢ ; i3 [1,3: 10] # ((1, 8)) ¢ ; i3 [1,3: ] ¢ ((1,9)) ¢ ; i3 [1,: ] ¢ ((1, 10)) ¢ ; i3 [1, ] ¢ ((2, 11)) ¢ ; i3 [,2] ¢ ((0,9)) ¢}

Next