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.36.50.22 with SMTP id j22mr1007458ita.10.1512021384689; Wed, 29 Nov 2017 21:56:24 -0800 (PST) X-Received: by 10.157.85.67 with SMTP id h3mr133867oti.10.1512021384599; Wed, 29 Nov 2017 21:56:24 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!news.kjsl.com!usenet.stanford.edu!i6no259699itb.0!news-out.google.com!x87ni330ita.0!nntp.google.com!i6no259695itb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 29 Nov 2017 21:56:24 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=97.117.255.82; posting-account=x5rpZwoAAABMN2XPwcebPWPkebpwQNJG NNTP-Posting-Host: 97.117.255.82 References: <0b6bd27e-e9ec-4854-bbb1-85e1d9ac92e1@googlegroups.com> <227d5a7f-6d5b-4b76-ac31-7d15bb6dc284@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <16c980c2-1fa6-4084-97ea-b576c75b99c3@googlegroups.com> Subject: Re: How to access an array using two different indexing schemes From: Jerry Injection-Date: Thu, 30 Nov 2017 05:56:24 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader02.eternal-september.org comp.lang.ada:49271 Date: 2017-11-29T21:56:24-08:00 List-Id: On Wednesday, November 29, 2017 at 1:56:59 PM UTC-7, Randy Brukardt wrote: > "AdaMagica" wrote in message > > Am Mittwoch, 29. November 2017 17:03:04 UTC+1 schrieb Shark8: > > > >> Procedure Do_Stuffs( Data : in out General_Real_Array ) is > >> Subtype Indexing is General_Real_Array(1..Data'Length); > >> Subtype Offset is General_Real_Array(0..Integer'Pred(Data'Length)); > >> > >> Indexed : Indexing renames Data; > >> Offseted : Offset renames Data; > > > > No, that doesn't work! See previous posts. > > Should have showed what does work: > > Indexed : Indexing renames Indexing(Data); > Offseted : Offset renames Offset(Data); > > The type conversions change the bounds as needed. Renames does not allocate > new memory. > > Randy. Combining Shark8's plan with Randy's change and wrapping into a main program like this: Procedure Shark8_And_Randy is Subtype Real is Float range Float'Range; -- Get rid of non-numeric. Type General_Real_Array is Array(Integer range <>) of Real; Procedure Do_Stuffs( Data : in out General_Real_Array ) is Subtype Indexing is General_Real_Array(1..Data'Length); Subtype Offset is General_Real_Array(0..Integer'Pred(Data'Length)); Indexed : Indexing renames Indexing(Data); Offseted : Offset renames Offset(Data); Begin -- Stuffs! null; End Do_Stuffs; Begin null; End Shark8_And_Randy; Results in GNAT complaining as such: shark8_and_randy.adb:9:37: renaming of conversion only allowed for tagged types shark8_and_randy.adb:10:35: renaming of conversion only allowed for tagged types