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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,653642c0bd258f9f X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Received: by 10.180.82.166 with SMTP id j6mr1247870wiy.1.1347850085811; Sun, 16 Sep 2012 19:48:05 -0700 (PDT) Path: q11ni104336480wiw.1!nntp.google.com!feeder2.cambriumusenet.nl!feeder1.cambriumusenet.nl!feeder3.cambriumusenet.nl!feed.tweaknews.nl!85.12.40.138.MISMATCH!xlned.com!feeder5.xlned.com!feed.xsnews.nl!border-3.ams.xsnews.nl!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border2.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!news.bbs-scene.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!gegeweb.org!aioe.org!.POSTED!not-for-mail From: "Vasiliy Molostov" Newsgroups: comp.lang.ada Subject: Re: 'Size of an object Date: Tue, 11 Sep 2012 20:21:46 +0400 Organization: None Message-ID: References: <97ff13ad-308a-416f-a300-6c7d9da3d71b@googlegroups.com> NNTP-Posting-Host: Xw13RWgh8yxgPSv0x3+H9w.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.02 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable Date: 2012-09-11T20:21:46+04:00 List-Id: Adam Beneschan =D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0) = =D0=B2 =D1=81=D0=B2=D0=BE=D1=91=D0=BC =D0=BF=D0=B8=D1=81=D1=8C=D0=BC=D0=B5= Tue, 11 Sep 2012 = 19:52:03 +0400: > I had a customer ask a simple question and found that I didn't really > know the answer, and I'm not even sure where there is a clear answer. > > The question has to do with X'Size where X is an object. RM 13.3(40) > says this "denotes the size in bits of the representation of the > object". Maybe I'm being dense, but this doesn't seem to clarify > things. RM says truth. always. This means you can supply representation clause f= or = X and ask lately in code about this representation. If you have not = supplied representation, it will be almost equal to system unit size = (8-bit byte or 16-bit word, or else). > Suppose you have an enumeration type with eight literals, and no other= > representation or aspect clauses apply to the type: > > type Enum is (E0, E1, E2, E3, E4, E5, E6, E7); > > I think Enum'Size should be 3 in most or all implementations. Now = > suppose > you have a local variable of that type: For intel x86 it would be a 8 or 16, or 32, depending on how memory = alignment is constrained for this object. You can redefine size to 3 by = = adding representation clause. > > procedure Proc is > E : Enum; > begin > Put_Line (Integer'Image (E'Size)); > end Proc; > > What would you expect E'Size to be, and why? In this case, it would be a default value of max(system unit size, defau= lt = memory alignment). > In a larger procedure, > what might you use 'Size on a local variable for; if you wouldn't ever= > use it on a local variable, then what kinds of *objects* (not types or= > subtypes) might you apply 'Size to, and what would you do with the val= ue? You can use it in bit string copy ops, in record representation clauses = or = any other, depending on purpose, a similar thing in C is a bit field = definitions inside 'struct' notation.