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.10.203 with SMTP id 72mr18053010iok.8.1511560136698; Fri, 24 Nov 2017 13:48:56 -0800 (PST) X-Received: by 10.157.5.211 with SMTP id 77mr1260925otd.0.1511560136603; Fri, 24 Nov 2017 13:48:56 -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!d140no5624611itd.0!news-out.google.com!193ni1149iti.0!nntp.google.com!d140no5624606itd.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 24 Nov 2017 13:48:56 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=71.209.130.105; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG NNTP-Posting-Host: 71.209.130.105 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <0a928bc7-9681-4975-a130-55bf0f3264d0@googlegroups.com> Subject: Re: How to access an array using two different indexing schemes From: Jerry Injection-Date: Fri, 24 Nov 2017 21:48:56 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Xref: feeder.eternal-september.org comp.lang.ada:48181 Date: 2017-11-24T13:48:56-08:00 List-Id: On Friday, November 24, 2017 at 10:37:30 AM UTC-7, A. Cervetti wrote: > use attribute 'Address: >=20 > with Ada.Text_IO; use Ada.Text_IO; > with Ada.Float_Text_IO; use Ada.Float_Text_IO; > with Ada.Numerics.Generic_Real_Arrays; >=20 > procedure Double_Array is > package Real_Array is new Ada.Numerics.Generic_Real_Arrays(Float); > use Real_Array; > =20 > x : Real_Vector(0 .. 4) :=3D (1.0, 2.0, 3.0, 4.0, 5.0); > y : Real_Vector(1 .. 5); > for Y'Address use X'Address; -- <<<<<<<<<<<<<<<<<<<< > =20 > begin > X(0) :=3D 20.0; > Put(X(0), 0, 0, 0); New_Line; > Put(Y(1), 0, 0, 0); New_Line; > end Double_Array; Nice. Thank you. That solves the "version control" or "bookkeeping" problem= , but it still requires allocating double memory, for y. I had hoped to use an access variable for the role of y so that only a tiny= amount of additional memory would be required, and somehow do a type conve= rsion of the y-pointer as it points at x, but I haven't been able yet to fi= gure out how to do the pointer type conversion. Is this even possible? Jerry