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: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!goblin3!goblin.stu.neva.ru!gegeweb.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Need help for constrained type Date: Thu, 06 Feb 2014 17:04:59 -0700 Organization: Also freenews.netfront.net; news.tornevall.net Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 7 Feb 2014 00:05:01 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="6bab1dce10a849dba13303bd95a0f77d"; logging-data="22128"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qRXf5qyxZ1Htk8hlx/0VjfAz5zS31qIM=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: Cancel-Lock: sha1:+A4o6A1CiQETI4lHYhBq9/LloVU= X-Original-Bytes: 2160 Xref: number.nntp.dca.giganews.com comp.lang.ada:184694 Date: 2014-02-06T17:04:59-07:00 List-Id: On 02/06/2014 09:13 AM, Gerd wrote: > > But i would like the indices of Usage_Info running from 0..len - 1 (C-style). But when I write > > type Memory_Block (len : Natural) is > record > Start_Address : Mem_Addr; > Block_Size : Natural; > Usage_Info : Mem_Array (0..len-1); > end record; That's what happens when you try to do C in Ada. Technically, you can't use a discriminant to determine the length of an array, only to determine a bound. The 2 are the same only when the lower bound is 1 (the Ada way). Since what you're supplying is not the length, but the 'Last, so you should name it that. -- Jeff Carter "When Bell Labs were invited to evaluate C against the DoD requirements [for Ada], they said that there was no chance of C meeting the requirements of readability, safety, etc. for which we were striving, and that it should not even be on the list of evaluated languages." William Whitaker 116