comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Array Help?
Date: Wed, 29 Feb 2012 12:40:57 -0800 (PST)
Date: 2012-02-29T12:40:57-08:00	[thread overview]
Message-ID: <160295e7-8a6a-4097-8b8e-52a1510ba918@r1g2000yqk.googlegroups.com> (raw)
In-Reply-To: wcck435wrj2.fsf@shell01.TheWorld.com

On Feb 29, 8:09 am, Robert A Duff <bobd...@shell01.TheWorld.com>
wrote:
> Adam Beneschan <a...@irvine.com> writes:
> >   type Integer_Array is array (Integer range <>) of Integer;
> >   A : Integer_Array (2 .. 7);
>
> Right, and this is a rich source of bugs.  You usually want
> arrays to start at 1, or sometimes 0 (assuming the index type
> is a signed integer type, which is almost always the case
> for unconstrained arrays).

I think most of my array subtypes start at 0 or 1.  Occasionally I
find a good reason to start at -1.  The other thing is that if I write
a procedure with an unconstrained array parameter P, I'll often
declare a local variable like

   A : Some_Array (P'Range);

where the array may or may not be the same array type as the
parameter.  It's very useful to be able to declare an array where the
index values mean the same thing as the index values into a different
array, rather than having to deal with some blasted +/- offset when
trying to work with parallel elements in the two arrays.

                       -- Adam



      parent reply	other threads:[~2012-02-29 20:42 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-28 20:15 Array Help? Will
2012-02-28 20:47 ` Ludovic Brenta
2012-02-28 22:11   ` Simon Wright
2012-02-28 23:09     ` Will
2012-02-29  0:24   ` Adam Beneschan
2012-02-28 20:50 ` Gautier write-only
2012-02-28 21:33 ` Simon Wright
2012-02-29  0:27   ` Adam Beneschan
2012-02-29  8:00     ` Simon Wright
2012-02-29  8:48       ` Simon Wright
2012-02-29  0:22 ` Adam Beneschan
2012-02-29 16:09   ` Robert A Duff
2012-02-29 16:50     ` Ludovic Brenta
2012-02-29 18:24       ` Robert A Duff
2012-02-29 19:45         ` stefan-lucks
2012-02-29 20:45           ` Jeffrey Carter
2012-02-29 21:27             ` stefan-lucks
2012-02-29 23:06           ` Robert A Duff
2012-03-02 13:45             ` stefan-lucks
2012-03-07 23:58             ` Randy Brukardt
2012-03-08 11:20               ` stefan-lucks
2012-03-09  2:02                 ` Randy Brukardt
2012-03-09  8:48                   ` stefan-lucks
2012-03-09 21:10                     ` Randy Brukardt
2012-03-15  2:55                     ` BrianG
2012-03-15  7:46                       ` stefan-lucks
2012-02-29 20:07         ` Dmitry A. Kazakov
2012-02-29 23:15           ` Robert A Duff
2012-03-01  8:54             ` Dmitry A. Kazakov
2012-03-01 14:06               ` Robert A Duff
2012-02-29 20:47         ` Simon Wright
2012-02-29 22:23           ` Robert A Duff
2012-02-29 23:27             ` Robert A Duff
2012-03-01  0:53               ` Adam Beneschan
2012-03-01  7:16               ` Ludovic Brenta
2012-03-01 14:03                 ` Robert A Duff
2012-03-08  0:11                   ` Randy Brukardt
2012-03-08  0:08               ` Randy Brukardt
2012-02-29 23:30             ` Simon Wright
2012-02-29 18:35     ` Jeffrey Carter
2012-02-29 22:59       ` Robert A Duff
2012-02-29 23:51         ` Jeffrey Carter
2012-03-01  3:03           ` Robert A Duff
2012-02-29 20:40     ` Adam Beneschan [this message]
replies disabled

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