comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison <dennison@escmail.orl.mmc.com>
Subject: Re: Unconstrained array aggregation..sq. peg into round hole?
Date: 1996/03/19
Date: 1996-03-19T00:00:00+00:00	[thread overview]
Message-ID: <314F211B.4823@escmail.orl.mmc.com> (raw)
In-Reply-To: 4ihrvo$hs5@dfw.dfw.net

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         |




  parent reply	other threads:[~1996-03-19  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 ` Ted Dennison [this message]
1996-03-19  0:00   ` Unconstrained array aggregation..sq. peg into round hole? Robert Dewar
1996-03-20  0:00 ` Robert I. Eachus
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