comp.lang.ada
 help / color / mirror / Atom feed
From: Micronian Coder <micronian2@gmail.com>
Subject: Re: 'Size of an object
Date: Tue, 11 Sep 2012 09:20:03 -0700 (PDT)
Date: 2012-09-11T09:20:03-07:00	[thread overview]
Message-ID: <9fcf7c0f-344b-45d4-a662-5b212915efee@googlegroups.com> (raw)
In-Reply-To: <97ff13ad-308a-416f-a300-6c7d9da3d71b@googlegroups.com>

That's a good question. I would expect it to be the size of the object, which could be anything really (8, 16, 32) and not the size of Enum'Size (ie. 3). If I'm not mistaken, this confusion is why AdaCore implemented an Object_Size attribute which sadly didn't make it into any recent version of Ada. A quick search on www.ada-auth.org turns up http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00319.txt?rev=1.5 , which is voted as NO ACTION. I should read the AI discussion to see what the ARG was thinking.


On Tuesday, September 11, 2012 8:52:03 AM UTC-7, 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.
> 
> 
> 
> 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.
> 
> 
> 
> 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:
> 
> 
> 
>    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 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?
> 
> 
> 
>                         -- thanks, Adam




  reply	other threads:[~2012-09-11 16:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-11 15:52 'Size of an object Adam Beneschan
2012-09-11 16:20 ` Micronian Coder [this message]
2012-09-11 16:21 ` Vasiliy Molostov
2012-09-11 16:27 ` Dmitry A. Kazakov
2012-09-11 16:28 ` björn lundin
2012-09-11 17:07 ` Shark8
2012-09-11 18:11 ` AdaMagica
2012-09-11 22:21   ` Adam Beneschan
replies disabled

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