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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,56525db28240414a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.78.106 with SMTP id a10mr275636pax.14.1343377736639; Fri, 27 Jul 2012 01:28:56 -0700 (PDT) Path: c10ni42258pbw.0!nntp.google.com!news2.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Keean Schupke Newsgroups: comp.lang.ada Subject: Re: Efficient Sequential Access to Arrays Date: Fri, 27 Jul 2012 01:21:18 -0700 (PDT) Organization: http://groups.google.com Message-ID: <9c180f15-28b5-46ca-929d-b731058d0a97@googlegroups.com> References: <01983f1c-f842-4b1f-a180-bcef531dad4c@googlegroups.com> <87ipdf4vh6.fsf@mid.deneb.enyo.de> <4ce44d2d-d789-42a0-a6ed-035f7f8d58be@googlegroups.com> NNTP-Posting-Host: 82.44.19.199 Mime-Version: 1.0 X-Trace: posting.google.com 1343377736 7869 127.0.0.1 (27 Jul 2012 08:28:56 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 27 Jul 2012 08:28:56 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=82.44.19.199; posting-account=T5Z2vAoAAAB8ExE3yV3f56dVATtEMNcM User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-07-27T01:21:18-07:00 List-Id: On Thursday, 26 July 2012 13:32:32 UTC+1, Keean Schupke wrote: > On Thursday, 26 July 2012 11:10:39 UTC+1, Brian Drummond wrote: > > On Thu, 26 Jul 2012 01:38:41 -0700, Keean Schupke wrote: > > > > &gt; This is an equivalent concept to nullable, so two questions: > > &gt; > > &gt; What is the literal for &#39;invalid&#39;, IE: > > &gt; > > &gt; X : Index := #INVALID -- we should be able to initialise to invalid. > > &gt; > > &gt; if X = #INVALID -- I want to be able to test for invalid. > > > > There&#39;s an attribute for that. > > > > if X&#39;Valid ... > > > > - Brian > > > So if I do > > if X'Valid then > Y(X) -- if X is the same type as the index of Y then no need to range check. > end if > > If I explicitly check 'Valid, the compiler should be able to omit some implicit range checks, as 'Valid is an explicit range check. > > > Cheers, > Keean. I am wondering if there is a way to use address arithmetic that would be just as safe as array indexing? What about something like: type Value_Type is limited private; type Index_Type is range <>; type Array_Type is array (Index_Type) of Value_Type; A : Array_Type; type Iterator = Address_Integer range A(A'First)'Address .. A(A'Last)'Address step Value_Type'Size; This would be safe as it could only contain the address of a valid record in the array, and the syntax could be neat with automatic dereferencing. Cheers, Keean.