From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,177ff20edf7f64cf X-Google-Attributes: gid103376,public From: Ted Dennison Subject: Re: Unconstrained array aggregation..sq. peg into round hole? Date: 1996/03/19 Message-ID: <314F211B.4823@escmail.orl.mmc.com>#1/1 X-Deja-AN: 143120186 references: <4ihrvo$hs5@dfw.dfw.net> content-type: text/plain; charset=us-ascii organization: Lockheed Martin Marine Systems mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.0 (X11; I; HP-UX A.09.01 9000/750) Date: 1996-03-19T00:00:00+00:00 List-Id: David Weller wrote: > > package Strange is > > type Real_Array is array (Natural range <>) of Float; > > type Real_Table is array (Natural range <>, Natural range <>) of Float; > ... > > An_Array : constant Real_Array := (0..Max-1 => Table(Max)(0..Max-1)); > -- incorrect # of indices? > > end Strange; Well, I don't have an Ada (95) compiler handy, but from my Ada 83 experience one thing jumps right out at me. In Ada 83 this would be illegal because Real_Table is an array with two dimensions, but you are indexing it like an array of arrays. This is a syntactic no-no right off the bat (which is what the compiler is pointing out). I don't believe there is a way to "convert" one dimension of a doubly dimensioned array into some kind of anonymous singly dimensioned array type, like this code is attempting to do. I don't know about Ada 95, but Ada 83 does not allow slices of multi-dimensioned arrays (after all, what would the type be?). You could try to correct this by defining Real_Table as an array of Real_Array's, but this won't compile either because you can't use an unconstrained array in another type declaration. If you don't mind constraining one index of the table, this will work (in Ada 83): package Strange is type Real_Array is array (Natural range <>) of Float; MAX : constant := 3; subtype Real_3_Array is Real_Array (0..Max-1); type Real_Table is array (Natural range <>) of Real_3_Array; Table : constant Real_Table := ( (20.0, 40.0, 80.0), (20.0, 40.0, 80.0), (20.0, 40.0, 80.0), (20.0, 40.0, 80.0), (60.0, 120.0, 240.0) ); An_Array : constant Real_Array := Table(Max); end Strange; -- T.E.D. | Work - mailto:dennison@escmail.orl.mmc.com | | Home - mailto:dennison@iag.net | | URL - http://www.iag.net/~dennison |