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!feeder.eternal-september.org!feeder.erje.net!1.eu.feeder.erje.net!news.etla.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Arrays in Ada 2012 Date: Thu, 8 Jun 2017 22:23:26 -0500 Organization: JSA Research & Innovation Message-ID: References: <35c6ac5a-3295-4fa4-8545-ca76c113dde4@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: franka.jacob-sparre.dk 1496978606 31301 24.196.82.226 (9 Jun 2017 03:23:26 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 9 Jun 2017 03:23:26 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:46928 Date: 2017-06-08T22:23:26-05:00 List-Id: "Dmitry A. Kazakov" 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.