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!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!xlned.com!feeder7.xlned.com!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Thu, 06 Feb 2014 18:37:01 +0100 From: "G.B." User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Need help for constrained type References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <52f3c83c$0$6559$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 06 Feb 2014 18:37:00 CET NNTP-Posting-Host: b547bd22.newsspool4.arcor-online.net X-Trace: DXC=dE@]JS71MT2QbA1[CgMQ004IUKgZA9nc\616M64>:Lh>_cHTX3j=jj0U^O On 06.02.14 17:13, Gerd wrote: > Is it possible to allocate "len" units, but address them from 0 .. len - 1? > > How can I do this? One approximation can make use of generics. The immediate mention of the Len with the object declaration will not be present. But otherwise the approximation preserves the "interface" of Memory_Block, except that the .Len component is no longer constant, and not guaranteed to be in sync with the length of .Usage_Info, if someone messes with it. generic Len : Natural; package Memory_Blocks is C_Style_Len : constant Integer := Len - 1; type Memory_Block is record Len : Natural := Memory_Blocks.Len; Start_Address : Mem_Addr; Block_Size : Natural; Usage_Info : Mem_Array (0..C_Style_Len); end record; end Memory_Blocks; package C_Style_Mem is new Memory_Blocks (2**16); mem : C_Style_Mem.Memory_Block; (A different approach might instead choose a function, C_Length (a renaming of Integer'Pred), such that mem : Memory_Block (C_Length (2**16)); will in effect let the index of Mem_Array be 0 .. Len.)