[comp.lang.ada] LRM Oddity

chuck@brain.UUCP (Chuck Shotton) (06/29/91)

I ran into this oddity today. Can someone please explain the rationale behind
it?

type record_type is record
   a, b: integer;
end record;

a_var         : array (1..3) of record_type := ((1,2), (3,4), (5,6)); -- syntax OK
another_var   : array (1..1) of record_type := ((1,2)); -- compiler error
one_more_var  : array (1..1) of record_type := (1 => (1,2)); -- syntax OK

Apparently, Ada requires that initialized arrays with only ONE element must
use positional specifications for the initialization data. But, if there is
more than one element, the positional specification (ex. 1 => ) is not required.

WHY? (I can only assume that it makes it clear that the "(1,2)" initializes to
a single array element and not two. Seems sort of odd....

-----------------------------------------------------------------------
Chuck Shotton                 Internet:  cshotton@girch1.med.uth.tmc.edu
BIAP Systems                  UUCP:      ...!buster!brain!chuck
"Your silly quote here."      AppleLink: D1683       MacNet: shotton