comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: 'Size of an object
Date: Tue, 11 Sep 2012 08:52:03 -0700 (PDT)
Date: 2012-09-11T08:52:03-07:00	[thread overview]
Message-ID: <97ff13ad-308a-416f-a300-6c7d9da3d71b@googlegroups.com> (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



             reply	other threads:[~2012-09-11 15:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-11 15:52 Adam Beneschan [this message]
2012-09-11 16:20 ` 'Size of an object 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
replies disabled

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