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.107.183.193 with SMTP id h184mr17081145iof.129.1511538769289; Fri, 24 Nov 2017 07:52:49 -0800 (PST) X-Received: by 10.157.81.193 with SMTP id d1mr1210922oth.13.1511538769154; Fri, 24 Nov 2017 07:52:49 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.stack.nl!usenet-its.stanford.edu!usenet.stanford.edu!i6no5402252itb.0!news-out.google.com!x87ni3369ita.0!nntp.google.com!d140no5407507itd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 24 Nov 2017 07:52:48 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2003:c7:83c9:d68a:40e3:26f3:2b96:8cea; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 2003:c7:83c9:d68a:40e3:26f3:2b96:8cea References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3f2c41db-3944-4b37-99b8-b71d55d5f8ed@googlegroups.com> Subject: Re: How to access an array using two different indexing schemes From: AdaMagica Injection-Date: Fri, 24 Nov 2017 15:52:49 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: feeder.eternal-september.org comp.lang.ada:48176 Date: 2017-11-24T07:52:48-08:00 List-Id: Am Freitag, 24. November 2017 13:33:25 UTC+1 schrieb Jeffrey R. Carter: > On 11/24/2017 12:42 PM, Jerry wrote: > > I want to access an array such as Real_Vector (built-in for Ada >=3D 20= 05) with two different indexing schemes. For example, I would access a Real= _Vector indexed (0 .. 4) when thinking of it as a times series and the same= data indexed (1 .. 5) when thinking of it as a vector. Another application= would be a vector indexed (-128 .. 127) because it fits my problem domain,= perhaps a spatial variable, but I need to index it as (0 .. 255) when thin= king of doing a Fast Fourier Transform on it. >=20 > I can't think of any situation when I'd need to access the same component= of an=20 > array using different indices, but I note that this compiles: >=20 > procedure Renaming is > subtype T1 is String (1 .. 5); > subtype T2 is String (2 .. T1'Length + 1); >=20 > S1 : T1 :=3D "Hello"; > S2 : T2 renames S1; > begin -- Renaming > null; > end Renaming; procedure Renaming is subtype T1 is String (1 .. 5); subtype T2 is String (1 .. 0); -- ! S1 : T1 :=3D "Hello"; S2 : T2 renames S1; begin -- Renaming Put (S1'First'Image); Put (S1 (S1'First)); Put (S2'First'Image); Put (S2 (S2'First)); Put (S1'Last 'Image); Put (S1 (S1'Last )); Put (S2'Last 'Image); Put (S2 (S2'Last )); New_Line; end Renaming; This results in 1H 1H 5o 5o Rememner that renamings ignore constraints.