Structure Display

Meaning

When a collateral clause is in a strong context where a primary yielding a structure value is expected, its constituent units are elaborated collaterally as usual, and the resulting values are used to conform the value of the fields of a new structure value of the expected mode. These collateral clauses are called structure displays, and play the role of structure denotations in Algol 68, even though they are not truly denotations.

The constituent units of a structure display are known as the field positions of the structure display. They are always elaborated in strong context with the mode of the corresponding structure mode field expected. The units are elaborated collaterally.

Consider the following structured mode with a couple of real fields and the declaration of a constant of that mode:

mode vector = (real x, y);
vector v1 = (3.14, 10)

The right hand side of an identity declaration is a strong context, and therefore the required mode is known at compile-time. In this case the mode expected is vector. The collateral clause (3.14, 10) can then recognized as a structure display of that particular mode, and its constituent units 3.14 and 10 become strong field positions with expected mode real. This allows the widening of 10 to 10.0 in this case.

When the context is not strong, however, structure displays cannot be recognized as such. Consider the following operator that adds two vectors:

op + = (vector a, b) vector:
   (x of a + x of b, y of a + y of b)

Again, the structure display in the body of the routine text ascribed to the operator + is in a strong context expecting a vector, so no problem there. But then consider the following formula that uses the just defined operator:

(1, 2) + (3, 4)

That is not valid code and a compiler will complain. The operands of a formula are in firm context, and the collateral clauses are recognized as such, which are void units. To remedy this we are forced to use casts in order to surround the collateral clauses with a strong context with required mode vector:

vector (1, 2) +  vector (3, 4)

Note that structure displays must have two or more field positions, or certain syntactic ambiguity known as Yoneda’s ambiguity would arise: given mode = m (ref m m); m nobuo, yoneda; the assignation nobuo := (yoneda) is ambiguous. This difficulty can be easily circumvented by using the non-ambiguous m of nobuo := yoneda.

Syntax

Simplified [RR 3.3.1.e:h]:

FIELD :: MODE field TAG.

e) strong structured with FIELDS FIELD mode collateral clause:
     FIELDS FIELD portrait.
f) FIELDS FIELD portrait:
     FIELDS portrait, and also token, FIELD portrait.
g) MODE field TAG portrait:
     strong MODE unit;
h) *structure display:
     strong structured with FIELDS FIELD mode collateral clause.

Note that and also token is the comma symbol in most representations.

Note how the structure mode in e has at least two fields.

See Also