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.68.132.69 with SMTP id os5mr3649232pbb.6.1330557353067; Wed, 29 Feb 2012 15:15:53 -0800 (PST) Path: h9ni24562pbe.0!nntp.google.com!news1.google.com!news2.google.com!news.glorb.com!solaris.cc.vt.edu!news.vt.edu!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 18:15:52 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <10615783-d4a9-4cbd-8971-53ba1100d6a0@b18g2000vbz.googlegroups.com> <17412419.40.1330534213855.JavaMail.geo-discussion-forums@vbva11> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 X-Trace: pcls6.std.com 1330557352 31571 192.74.137.71 (29 Feb 2012 23:15:52 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 29 Feb 2012 23:15:52 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:hCpv9XTMPWp+048rai803hMcQEQ= Content-Type: text/plain; charset=us-ascii Date: 2012-02-29T18:15:52-05:00 List-Id: "Dmitry A. Kazakov" writes: > On Wed, 29 Feb 2012 13:24:10 -0500, Robert A Duff wrote: >> That will raise C_E. No, Assert_Failure. >...IMHO, that's a language design flaw -- inside >> Foo, Param'First ought to be 1. > > Nope. Consider index of an enumeration type. I'm talking about the example where the array is (1) unconstrained, (2) the index type is Positive, and (3) the programmer wants all array objects A to have A'First = Positive'First. Nothing to do with enumeration types. Ada allows you to fix 'First and 'Last, and it allows you to let both vary. What's missing is a way to fix 'First, but allow 'Last to vary. I sort of implied that a predicate should do that, but that's wrong. There should be SOME way to do it. And for completeness, I'd allow fixing 'Last, but allowing 'First to vary, although that's much less useful. Ada 9X proposed a solution based on discriminated arrays. When an array index is an enum, it's almost always constrained (i.e. 'First and 'Last are both fixed), slices are usually meaningless, and of course 1 isn't a value of any enum type. I'm certainly not saying "all arrays should start at 1". I'm saying "there should a way to declare an array type such that all objects of that type start at 1 (or any other value) while allowing 'Last to vary". - Bob