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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: How to access an array using two different indexing schemes Date: Fri, 24 Nov 2017 13:33:23 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 24 Nov 2017 12:33:23 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="8972b0c4b7d5d6b1f0564460d28f5fe8"; logging-data="24177"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+lhW3yJm1/HwsOnRP9T4T0E659q9qykfw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 In-Reply-To: Content-Language: en-US Cancel-Lock: sha1:4MIy3Ya5lhhTcQIeltAP+jq+e4U= Xref: feeder.eternal-september.org comp.lang.ada:49129 Date: 2017-11-24T13:33:23+01:00 List-Id: On 11/24/2017 12:42 PM, Jerry wrote: > I want to access an array such as Real_Vector (built-in for Ada >= 2005) 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 thinking of doing a Fast Fourier Transform on it. I can't think of any situation when I'd need to access the same component of an array using different indices, but I note that this compiles: procedure Renaming is subtype T1 is String (1 .. 5); subtype T2 is String (2 .. T1'Length + 1); S1 : T1 := "Hello"; S2 : T2 renames S1; begin -- Renaming null; end Renaming; -- Jeff Carter "I wave my private parts at your aunties." Monty Python & the Holy Grail 13