comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Arrays in Ada 2012
Date: Thu, 8 Jun 2017 22:23:26 -0500
Date: 2017-06-08T22:23:26-05:00	[thread overview]
Message-ID: <ohd4be$ui5$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: ohat3q$lon$1@gioia.aioe.org

"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:ohat3q$lon$1@gioia.aioe.org...
> On 08/06/2017 02:51, Randy Brukardt wrote:
>
>> The definition of 'Size is stupid, so you need rounding like that to be
>> portable.
>
> You mean being bit size or being kind of weakly typed (universal integer). 
> I disagree on the first and agree on the second. It possibly should be 
> overloaded:
>
>   function 'Size (...) return Storage_Count; -- Storage units
>   function 'Size (...) return Storage_Size;  -- Bits

The definition of 'Size is stupid, because it's neither the bit size nor the 
usual allocation size, but a weird hybrid of both. It's primary effect is to 
provide a lower bound for packing, which is hardly ever what you want to 
limit. (Why would you want to prevent someone from packing some component?)

And 'Size has no effect at all on what you can write in other rep. clauses, 
like 'Component_Size and record representations. So setting 'Size almost 
never does what you want (unless the compiler tries to be friendly -- but 
that runs into problems with the required default value of Size).

Thus GNAT (and soon Ada) introduced 'Object_Size, which gives the UPPER 
bound on the allocated size. A much more useful thing to bound - you can 
ensure that type Byte really only uses a byte, for instance.

                                    Randy.





  reply	other threads:[~2017-06-09  3:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-06 11:47 Arrays in Ada 2012 Anatoly Chernyshev
2017-06-06 12:17 ` Dmitry A. Kazakov
2017-06-06 13:17   ` Simon Wright
2017-06-06 13:57     ` Dmitry A. Kazakov
2017-06-06 21:59       ` Simon Wright
2017-06-06 13:19 ` AdaMagica
2017-06-06 20:56   ` Randy Brukardt
2017-06-07  7:06     ` Dmitry A. Kazakov
2017-06-07 11:47       ` Anatoly Chernyshev
2017-06-07 12:15         ` Dmitry A. Kazakov
2017-06-08  0:55         ` Randy Brukardt
2017-06-08  0:51       ` Randy Brukardt
2017-06-08  7:07         ` Dmitry A. Kazakov
2017-06-09  3:23           ` Randy Brukardt [this message]
2017-06-18  2:14 ` Arrays in Ada 2020 Ivan Levashev
2017-06-18  3:00   ` Nasser M. Abbasi
2017-06-18 12:06     ` Robert Eachus
2017-06-18 20:15       ` Simon Wright
2017-06-20 13:33         ` Robert Eachus
2017-06-19  6:36       ` Ivan Levashev
2017-06-19 12:06         ` AdaMagica
2017-06-23  1:17           ` Randy Brukardt
2017-06-18 20:15     ` Pascal Obry
replies disabled

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