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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2ac407a2a34565a9 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Received: by 10.50.158.229 with SMTP id wx5mr9524169igb.0.1330548154386; Wed, 29 Feb 2012 12:42:34 -0800 (PST) Path: h9ni24140pbe.0!nntp.google.com!news2.google.com!postnews.google.com!r1g2000yqk.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Array Help? Date: Wed, 29 Feb 2012 12:40:57 -0800 (PST) Organization: http://groups.google.com Message-ID: <160295e7-8a6a-4097-8b8e-52a1510ba918@r1g2000yqk.googlegroups.com> References: <10615783-d4a9-4cbd-8971-53ba1100d6a0@b18g2000vbz.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1330548154 9393 127.0.0.1 (29 Feb 2012 20:42:34 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 29 Feb 2012 20:42:34 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r1g2000yqk.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-02-29T12:40:57-08:00 List-Id: On Feb 29, 8:09=A0am, Robert A Duff wrote: > Adam Beneschan writes: > > =A0 type Integer_Array is array (Integer range <>) of Integer; > > =A0 A : Integer_Array (2 .. 7); > > Right, and this is a rich source of bugs. =A0You 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