Legality of -1..10 in loops 86-07-23 AI-00148/05 1
| !standard 03.06.01 (02) 86-07-23 AI-00148/05
| !class ramification 84-02-06
| !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 board-approved 84-06-29
!status committee-approved 84-02-06
!status received 84-01-10
!references 83-00211, 83-00216, 83-00218, 83-00219, 83-00220, 83-00228,
83-00309
!topic Legality of -1..10 in loops
!summary 84-07-13
The range -1..10 is illegal as the discrete range in an iteration rule,
constrained array type definition, and entry family declaration, since -1 is
an expression having a form prohibited by 3.6.1(2), and the other rules of
the language do not determine a unique type for the bounds. The possibility
of adopting a more liberal rule in a future version of the language will be
studied. Note, however, that instead of writing -1..10, one can always write
INTEGER range -1..10 or declare -1 as a constant and use the constant name in
place of the expression, -1; often it will be appropriate to use the
attribute 'RANGE in place of an explicit range such as -1..10.
!question 84-07-13
Is it really intended that -1..10 be an illegal discrete range in an
iteration rule, even when INTEGER is the only predefined non-universal
integer type?
!response 84-03-16
Yes, this is the intent. Moreover, there is no ambiguity in the wording,
there are no implementation difficulties in enforcing the rule, and the
validation tests check that such ranges are illegal in this context.
Finally, the rule does not restrict programming power since one can always
write INTEGER range -1 ..10 or declare -1 as a constant and use the constant
name in place of the expression, -1; often it will be appropriate to use the
attribute 'RANGE in place of an explicit range such as -1..10.
There is no ambiguity when INTEGER is the only predefined non-universal
integer type. The only rules that can be used to resolve the type of the
bounds are given explicitly in 3.6.1(2): the type must be discrete and both
bounds must have the same type. There are always at least two integer types
that satisfy these rules, INTEGER and universal_integer, so -1..10 is illegal
even when INTEGER is the only non-universal type that has been declared.