comp.lang.ada
 help / color / mirror / Atom feed
* 'Size of an object
@ 2012-09-11 15:52 Adam Beneschan
  2012-09-11 16:20 ` Micronian Coder
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Adam Beneschan @ 2012-09-11 15:52 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-09-17  2:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-11 15:52 'Size of an object Adam Beneschan
2012-09-11 16:20 ` Micronian Coder
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

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