Use of others in a multidimensional aggregate 86-07-23 AI-00177/04 1 | !standard 04.03.02 (08) 86-07-23 AI-00177/04 | !class binding interpretation 84-01-19 | !status approved by WG9/AJPO 86-07-22 | !status approved by Director, AJPO 86-07-22 | !status approved by WG9/Ada Board 86-07-22 | !status approved by Ada Board 86-07-22 !status WG14/ADA Board approved 84-11-27 !status WG14-approved 84-11-27 !status board-approved 84-11-26 !status committee-approved 84-06-28 !status work-item 84-06-11 !status received 84-01-19 !references 83-00261 !topic Use of others in a multidimensional aggregate !summary 84-12-10 An others choice is allowed if an aggregate is not a subaggregate and is the expression of a component association of an enclosing (array or record) aggregate. An others choice is also allowed if an aggregate is a subaggregate of a multidimensional array aggregate that is in one of the contexts specified by 4.3.2(5-8). !question 84-09-10 Consider the following declarations: type A_2dim is array (INTEGER range <>, INTEGER range <>) of STRING (1..4); type A_1dim is array (INTEGER range <>) of STRING (1..4); procedure P (Var : A_2dim); procedure Q (Var : A_1dim); Which of the following aggregates are illegal because of their use of OTHERS? P (Var => (1 => (2 => (others => 'a') )) ); Q (Var => (1 => (others => 'a'))); P (Var => (1 => (others => "abcd"))); !recommendation 84-12-10 An others choice is allowed if an aggregate is not a subaggregate and is the expression of a component association of an enclosing (array or record) aggregate. An others choice is also allowed if an aggregate is a subaggregate of a multidimensional array aggregate that is in one of the contexts specified by 4.3.2(5-8). Consequently, the following aggregates are legal because (others => 'a') is not a subaggregate: P (Var => (1 => (2 => (others => 'a') )) ); -- legal Q (Var => (1 => (others => 'a'))); -- legal but the aggregate in the next call is illegal because (others => "abcd") is a Use of others in a multidimensional aggregate 86-07-23 AI-00177/04 2 subaggregate of a multidimensional array aggregate and P's formal parameter is not constrained, so the multidimensional aggregate does not appear in one of the permitted contexts: P (Var => (1 => (others => "abcd"))); -- illegal !discussion 84-09-10 4.3.2(8) specifies one of the conditions under which an others choice is allowed in an aggregate, namely, an others choice is allowed if: "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 aggregate enclosing (others => 'a') is certainly a multidimensional array aggregate in the call to P, and this multidimensional aggregate does not appear in one of the three contexts permitted by 4.3.2(5-8) so 4.3.2(8) seems to say that the first call to P contains an illegal others choice. But the aggregate in the call to Q is legal because the (others => 'a') aggregate appears as the component association of an enclosing ONE-dimensional array aggregate. When (others => 'a') is not a subaggregate of a multidimensional array, it is inconsistent to allow its occurrence only to specify component values for one-dimensional arrays. The intent was to allow such an aggregate except when it is being used as a subaggregate of a multidimensional array aggregate, e.g., P (Var => (1 => (others => "abcd")) ); -- illegal The rule in 4.3.2(8) should have distinguished whether the component association occurs in a subaggregate or not. In particular, only if an aggregate is a subaggregate does the legality of a component association specifying an others choice depend on the context in which the containing multidimensional aggregate appears.