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-7-bit Received: by 10.204.143.143 with SMTP id v15mr87046bku.8.1330531745485; Wed, 29 Feb 2012 08:09:05 -0800 (PST) Path: t13ni83947bkb.0!nntp.google.com!news2.google.com!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!panix!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Array Help? Date: Wed, 29 Feb 2012 11:09:04 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <10615783-d4a9-4cbd-8971-53ba1100d6a0@b18g2000vbz.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 X-Trace: pcls6.std.com 1330531745 7853 192.74.137.71 (29 Feb 2012 16:09:05 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 29 Feb 2012 16:09:05 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:jI6bW/eBpfLjujup+bXZgHXNu+s= Content-Type: text/plain; charset=us-ascii Date: 2012-02-29T11:09:04-05:00 List-Id: Adam Beneschan 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). In Ada 2012, you can say: type Integer_Array is array (Positive range <>) of Integer with Dynamic_Predicate => Integer_Array'First = 1; or: type Integer_Array is array (Natural range <>) of Integer with Dynamic_Predicate => Integer_Array'First = 0; Now 'Last can be anything you like, but 'First is fixed. In GNAT, you can write "Predicate" instead of "Dynamic_Predicate". - Bob