4.3.2 Array Aggregates If the type of an aggregate is a one-dimensional array type, then each choice must specify values of the index type, and the expression of each component association must be of the component type. If the type of an aggregate is a multidimensional array type, an n-dimensional aggregate is written as a one-dimensional aggregate, in which the expression specified for each component association is itself written as an (n-1)-dimensional aggregate which is called a subaggregate; the index subtype of the one-dimensional aggregate is given by the first index position of the array type. The same rule is used to write a subaggregate if it is again multidimensional, using successive index positions. A string literal is allowed in a multidimensional aggregate at the place of a one-dimensional array of a character type. In what follows, the rules concerning array aggregates are formulated in terms of one-dimensional aggregates. Apart from a final component association with the single choice others, the rest (if any) of the component associations of an array aggregate must be either all positional or all named. A named association of an array aggregate is only allowed to have a choice that is not static, or likewise a choice that is a null range, if the aggregate includes a single component association and this component association has a single choice. An others choice is static if the applicable index constraint is static. The bounds of an array aggregate that has an others choice are determined by the applicable index constraint. An others choice is only allowed if the aggregate appears in one of the following contexts (which defines the applicable index constraint): (a) The aggregate is an actual parameter, a generic actual parameter, the result expression of a function, or the expression that follows an assignment compound delimiter. Moreover, the subtype of the corresponding formal parameter, generic formal parameter, function result, or object is a constrained array subtype. For an aggregate that appears in such a context and contains an association with an others choice, named associations are allowed for other associations only in the case of a (nongeneric) actual parameter or function result. If the aggregate is a multidimensional array, this restriction also applies to each of its subaggregates. (b) The aggregate is the operand of a qualified expression whose type mark denotes a constrained array subtype. (c) The aggregate is the expression of the component association of an enclosing (array or record) aggregate. Moreover, if this enclosing aggregate is a multidimensional array aggregate then it is itself in one of these three contexts. The bounds of an array aggregate that does not have an others choice are determined as follows. For an aggregate that has named associations, the bounds are determined by the smallest and largest choices given. For a positional aggregate, the lower bound is determined by the applicable index constraint if the aggregate appears in one of the contexts (a) through (c); otherwise, the lower bound is given by S'FIRST where S is the index subtype; in either case, the upper bound is determined by the number of components. The evaluation of an array aggregate that is not a subaggregate proceeds in two steps. First, the choices of this aggregate and of its subaggregates, if any, are evaluated in some order that is not defined by the language. Second, the expressions of the component associations of the array aggregate are evaluated in some order that is not defined by the language; the expression of a named association is evaluated once for each associated component. The evaluation of a subaggregate consists of this second step (the first step is omitted since the choices have already been evaluated). For the evaluation of an aggregate that is not a null array, a check is made that the index values defined by choices belong to the corresponding index subtypes, and also that the value of each subcomponent of the aggregate belongs to the subtype of this subcomponent. For an n-dimensional multidimensional aggregate, a check is made that all (n-1)-dimensional subaggregates have the same bounds. The exception CONSTRAINT_ERROR is raised if any of these checks fails. Note: The allowed contexts for an array aggregate including an others choice are such that the bounds of such an aggregate are always known from the context. Examples of array aggregates with positional associations: (7, 9, 5, 1, 3, 2, 4, 8, 6, 0) TABLE'(5, 8, 4, 1, others => 0) -- see 3.6 Examples of array aggregates with named associations: (1 .. 5 => (1 .. 8 => 0.0)) -- two-dimensional (1 .. N => new CELL) -- N new cells, in particular for N = 0 TABLE'(2 | 4 | 10 => 1, others => 0) SCHEDULE'(MON .. FRI => TRUE, others => FALSE) -- see 3.6 SCHEDULE'(WED | SUN => FALSE, others => TRUE) Examples of two-dimensional array aggregates: -- Three aggregates for the same value of type MATRIX (see 3.6): ((1.1, 1.2, 1.3), (2.1, 2.2, 2.3)) (1 => (1.1, 1.2, 1.3), 2 => (2.1, 2.2, 2.3)) (1 => (1 => 1.1, 2 => 1.2, 3 => 1.3), 2 => (1 => 2.1, 2 => 2.2, 3 => 2.3)) Examples of aggregates as initial values: A : TABLE := (7, 9, 5, 1, 3, 2, 4, 8, 6, 0); -- A(1)=7, A(10)=0 B : TABLE := TABLE'(2 | 4 | 10 => 1, others => 0); -- B(1)=0, B(10)=1 C : constant MATRIX := (1 .. 5 => (1 .. 8 => 0.0)); -- C'FIRST(1)=1, C'LAST( D : BIT_VECTOR(M .. N) := (M .. N => TRUE); -- see 3.6 E : BIT_VECTOR(M .. N) := (others => TRUE); F : STRING(1 .. 1) := (1 => 'F'); -- a one component aggregate: same as "F" References: actual parameter 6.4.1, aggregate 4.3, array type 3.6, assignment compound delimiter 5.2, choice 3.7.3, component 3.3, component association 4.3, component type 3.3, constrained array subtype 3.6, constraint 3.3, constraint_error exception 11.1, dimension 3.6, evaluate 4.5, expression 4.4, formal parameter 6.1, function 6.5, in some order 1.6, index constraint 3.6.1, index range 3.6, index subtype 3.6, index type 3.6, named component association 4.3, null array 3.6.1, object 3.2, positional component association 4.3, qualified expression 4.7, raising of exceptions 11, static expression 4.9, subcomponent 3.3, type 3.3