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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,379f9c2a66a5ddc8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news2.google.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx01.iad01.newshosting.com!209.197.12.246.MISMATCH!nx02.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!transit3.readnews.com!textspool1.readnews.com!news-out.readnews.com!postnews3.readnews.com!not-for-mail Date: Mon, 13 Sep 2010 14:31:56 -0400 From: "Peter C. Chapin" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.9) Gecko/20100825 Lightning/1.0b2 Thunderbird/3.1.3 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Question about package Interfaces. References: <4c8d7a8e$0$2408$4d3efbfe@news.sover.net> <4c8e2be0$0$2414$4d3efbfe@news.sover.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4c8e6e94$0$2400$4d3efbfe@news.sover.net> Organization: SoVerNet (sover.net) NNTP-Posting-Host: 8014f07d.news.sover.net X-Trace: DXC=H\8V04iQ4XCb5X7jJYA1FBK6_LM2JZB_CYHO@RciHi`C:WUUlR<856Oa1AiF885SnH;516cKP5fSI X-Complaints-To: abuse@sover.net Xref: g2news1.google.com comp.lang.ada:14050 Date: 2010-09-13T14:31:56-04:00 List-Id: On 2010-09-13 10:15, Robert A Duff wrote: > You can say "for A'Component_Size use 8;". For records, > you can specify the size of each component. For standalone > objects, you can specify 'Size. > > But my point was just that the 'Size of an object > is not guaranteed to be the same as the 'Size of > its subtype. Okay I think I'm understanding. So for example: declare type Byte is mod 2**8; for Byte'Size use 8; -- The subtype has this size. X : Byte; -- Could be more than 8 bits. for X'Size use 8; -- Except no.. must be 8 bits (is this legal). type Byte_Array is array(Natural range <>) of Byte; for Byte_Array'Component_Size use 8; -- Each array component is 8 bits. begin null; end; When you say "object" I understand you to mean the in-memory representation of an entity. > You might want to look into the GNAT-specific > 'Object_Size attribute. I looked it up, thanks. It was helpful. So I see that at least one issue is related to alignment. So in the Byte_Array declaration above, without the Component_Size declaration the compiler could use, say, 16 bits for each component to force word (2 byte) alignment on the components if it thought there was some advantage in doing so. However, with the Component_Size declaration the compiler must pack the components (since all 8 bits are needed for the representation). Does that sound right? Peter