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: 103376,653642c0bd258f9f X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.75.106 with SMTP id b10mr3521596paw.32.1347383225769; Tue, 11 Sep 2012 10:07:05 -0700 (PDT) Received: by 10.68.232.9 with SMTP id tk9mr1454213pbc.0.1347383225753; Tue, 11 Sep 2012 10:07:05 -0700 (PDT) Path: a8ni4572pbd.1!nntp.google.com!4no1130187pbn.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 11 Sep 2012 10:07:05 -0700 (PDT) In-Reply-To: <97ff13ad-308a-416f-a300-6c7d9da3d71b@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.20.190.126; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC NNTP-Posting-Host: 69.20.190.126 References: <97ff13ad-308a-416f-a300-6c7d9da3d71b@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: 'Size of an object From: Shark8 Injection-Date: Tue, 11 Sep 2012 17:07:05 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-09-11T10:07:05-07:00 List-Id: On Tuesday, September 11, 2012 9:52:03 AM UTC-6, Adam Beneschan wrote: > 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. >=20 > 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. >=20 > 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 suppos= e > you have a local variable of that type: >=20 > procedure Proc is > E : Enum; > begin > Put_Line (Integer'Image (E'Size)); > end Proc; >=20 > What would you expect E'Size to be, and why? 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 value? Well, 8, if it's on an x86 machine. There's no Pragma Pack, or Optimize(Space) so that means that the machine's= byte-size or word-size would make sensible choices for the compiler: the p= acking/unpacking could be too expensive WRT memory/processing-time if that = were the default for everything [every access to every variable having to b= e packed/unpacked - calculated on - repacked and stored].