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: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Unconstrained array aggregation..sq. peg into round hole? Date: 1996/03/20 Message-ID: #1/1 X-Deja-AN: 143213703 references: <4ihrvo$hs5@dfw.dfw.net> organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1996-03-20T00:00:00+00:00 List-Id: In article <4ihrvo$hs5@dfw.dfw.net> dweller@dfw.net (David Weller) writes: > I must confess I don't use such strange constnat initializations > typically, so I'm a little rusty on figuring out a solution. > Suggestions are welcome... It isn't a GNAT bug, and it is an Ada rule, but one of the weirder gotchas. (An element of a one dimensional array is a name not a slice, so this case only comes up when you have two dimensional to one dimensional and forget to sprinkle the right syntactic sugar... > package Strange is > type Real_Array is array (Natural range <>) of Float; > type Real_Table is array (Natural range <>, Natural range <>) of Float; -- try: type Real_Table is array (Natural range <>) of Real_Array; > MAX : constant := 3; > 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) ); -- the constant is fine... ;-) > An_Array : constant Real_Array; > private > An_Array : constant Real_Array := (0..Max-1 => Table(Max)(0..Max-1)); -- An_Array : constant Real_Array := Table(Max); > end Strange; In Ada there is a difference between Table(2)(3) and Table(2,3), in C there isn't. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...