comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@spectre.mitre.org (Robert I. Eachus)
Subject: Re: Unconstrained array aggregation..sq. peg into round hole?
Date: 1996/03/20
Date: 1996-03-20T00:00:00+00:00	[thread overview]
Message-ID: <EACHUS.96Mar19201632@spectre.mitre.org> (raw)
In-Reply-To: 4ihrvo$hs5@dfw.dfw.net


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...




  parent reply	other threads:[~1996-03-20  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-03-17  0:00 Unconstrained array aggregation..sq. peg into round hole? David Weller
1996-03-19  0:00 ` Unconstrained array aggregation..sq. peg i John Hutchison x2141
1996-03-19  0:00 ` Unconstrained array aggregation..sq. peg into round hole? Ted Dennison
1996-03-19  0:00   ` Robert Dewar
1996-03-20  0:00 ` Robert I. Eachus [this message]
1996-03-20  0:00   ` Robert A Duff
1996-03-20  0:00     ` Keith Thompson
1996-03-21  0:00   ` Robert I. Eachus
1996-03-22  0:00     ` Robert Dewar
1996-03-25  0:00   ` Robert I. Eachus
1996-03-25  0:00     ` Robert Dewar
1996-03-20  0:00 ` Jon S Anthony
1996-03-20  0:00   ` David Weller
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox