OTHERS choices and static index constraints 86-07-23 AI-00310/04 1
| !standard 04.03.02 (03) 86-07-23 AI-00310/04
| !class binding interpretation 84-10-31
| !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 approved by WG9/ADA Board 85-02-26
!status committee-approved 84-11-26
!status work-item 84-11-01
!status received 84-10-31
!references 83-00461
!topic OTHERS choices and static index constraints
!summary 84-11-01
An others choice is static if the corresponding index subtype is static and
if the corresponding index bounds were specified with a static discrete range
in the applicable index constraint.
!question 84-12-10
If an aggregate has more than one component association, and the last
component association has an others choice, then the others choice must be
static. 4.3.2(3) defines a static others choice as follows: "An OTHERS
choice is static if the applicable index constraint is static." Now consider
the following example (drawn from test B43201B-B of Version 1.5):
N : INTEGER := 3;
subtype NON_STATIC is INTEGER range 1..N;
type ARR is array (NON_STATIC, 1..3) of INTEGER;
...
ARR'(2 => (1..3 => 2),
others => (1..3 => 3)) -- illegal
ARR'(1..3 => (2 => 2,
others => 3)) -- legal?
Both aggregates require static others choices. The first aggregate is
clearly illegal; the corresponding index constraint is non-static. Is the
second aggregate also illegal?
!recommendation 84-11-01
An others choice is static if the corresponding index subtype is static and
if the corresponding index bounds were specified with a static discrete range
in the applicable index constraint.
!discussion 84-10-31
One might argue that the second aggregate is illegal because the
corresponding index constraint is (NON_STATIC, 1..3), and this index
OTHERS choices and static index constraints 86-07-23 AI-00310/04 2
constraint is non-static. (4.9(11) says "a static index constraint is an
index constraint for which each index subtype of the corresponding array type
is static and in which each discrete range is static.") Since the term "index
constraint" refers to a syntax rule [1.5(6)], there is no one-dimensional
corresponding index constraint that could be considered non-static.
On the other hand, one might argue that the second aggregate is legal because
4.3.2(2) says "the rules concerning array aggregates are formulated in terms
of one-dimensional aggregates," implying that as long as the corresponding
dimension has a static index subtype and has bounds specified with a static
discrete range, an others choice is considered to be static.
Either interpretation is easy to implement. The second interpretation (which
makes the second aggregate legal) is also more intuitive.
The ACVC test in Version 1.5 says the second aggregate is legal, but this
test was protested by an implementer who pointed out the first argument. It
has since been argued that the test correctly reflects the intent of the
Standard and should not be withdrawn from release 1.5 or changed in release
1.6.
Since the intent was to consider the staticness of index bounds for each
dimension separately, an others choice should be considered static as long as
the corresponding index bounds of the applicable index constraint were
specified with a static discrete range; the corresponding index subtype must
also be static. This interpretation makes the second aggregate legal and
means the Version 1.5 test is correct.