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=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.129.62.37 with SMTP id l37mr6018727ywa.96.1504351287420; Sat, 02 Sep 2017 04:21:27 -0700 (PDT) X-Received: by 10.36.111.201 with SMTP id x192mr36794itb.13.1504351287382; Sat, 02 Sep 2017 04:21:27 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!paganini.bofh.team!weretis.net!feeder6.news.weretis.net!feeder.usenetexpress.com!feeder-in1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!v20no1034643qtg.0!news-out.google.com!80ni1038itk.0!nntp.google.com!127no71470itw.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 2 Sep 2017 04:21:27 -0700 (PDT) In-Reply-To: <47cc6474-8b75-4644-92d0-bd1f694c20e7@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=83.255.112.230; posting-account=NT38RwoAAAB4_OO_uw8yHtNaa9Hkjukk NNTP-Posting-Host: 83.255.112.230 References: <4dc188de-802b-41ad-9cdd-b8246eb9a1c7@googlegroups.com> <47cc6474-8b75-4644-92d0-bd1f694c20e7@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <338b355a-dee4-4c73-b00e-09d9a8430fb1@googlegroups.com> Subject: Re: Community Input for the Maintenance and Revision of the Ada Programming Language From: =?UTF-8?B?Sm9oYW4gU8O2ZGVybGluZCDDhXN0csO2bQ==?= Injection-Date: Sat, 02 Sep 2017 11:21:27 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:47886 Date: 2017-09-02T04:21:27-07:00 List-Id: > 2. Allow a special indexing syntax, that I called relative indexing. Addi= ng a Unary + operator (that has no other purpose ! :-) ) in front of an ind= ex expression means starting from A'First. Unary plus would then become the= ordinal operator. >=20 > A(+i) simply means A(A'First +i).=20 >=20 > This is an elegant and above all retro-compatible way of permitting to st= art every array at zero which is easier in algorithms, cf. Dijkstra (EWD 83= 1 "Why numbering should start at zero") or Wirth's Oberon. Using A'Range is= not possible outside the basic cases. Anytime you want to compute indexes = you fall on relative indexes from 0 to N-1 and convoluted expressions that = add or suppress A'First. I usually cast a array to array that starts at zero index when implementing= algorithms. type Integer_Array is array (Integer range <>) of Integer; procedure Algorithm (Item : Integer_Array) is use Ada.Assertions; X : Integer_Array (0 .. Item'Length - 1) with Address =3D> Item'Address; begin for I in 0 .. Item'Length - 1 loop Assert (X (I) =3D Item (Item'First + I)); end loop; end Algorithm;