comp.lang.ada
 help / color / mirror / Atom feed
From: Jeffrey Carter <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: Need help for constrained type
Date: Thu, 06 Feb 2014 17:04:59 -0700
Date: 2014-02-06T17:04:59-07:00	[thread overview]
Message-ID: <ld17vb$ljg$2@dont-email.me> (raw)
In-Reply-To: <e16cb161-a199-48b1-ac53-a783198da0ac@googlegroups.com>

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


      parent reply	other threads:[~2014-02-07  0:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-06 16:13 Need help for constrained type Gerd
2014-02-06 17:30 ` Niklas Holsti
2014-02-06 18:03   ` adambeneschan
2014-02-06 18:37     ` Niklas Holsti
2014-02-06 18:57       ` adambeneschan
2014-02-06 17:37 ` G.B.
2014-02-07 14:11   ` Mike H
2014-02-10 11:40     ` G.B.
2014-02-07  0:04 ` Jeffrey Carter [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox