comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Packed array size question....
Date: 1997/03/16
Date: 1997-03-16T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680001603971621360001@news.ni.net> (raw)
In-Reply-To: 01bc300c$247f6200$0e096dce@my-pc.neosoft.com

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1403 bytes --]


In article <01bc300c$247f6200$0e096dce@my-pc.neosoft.com>, "Pat Rogers"
<progers@acm.org> wrote:

>> You have to admit that the attribute
>> 
>> X'Size_In_Storage_Elements 
>> 
>> would make a lot of sense.  In practice, knowing the number of storage
>> elements occupied by an object is much more useful than knowing the
>number
>> of bits.
>> 
>> Surprisingly, this attribute was not included in Ada 95!
>
>From the RM:
>
>145     S�Max_Size_In_Storage_Elements
>        For every subtype S:
>
>146     Denotes the maximum value for Size_In_Storage_Elements that will be
>requested via Allocate for an
>        access type whose designated subtype is S. The value of this
attribute is
>of type universal_integer. 
>        See 13.11.1.
>
>Close enough?

No, because that attribute only applies to memory allocated via an allocator.  

I wanted an attribute I could apply to stack objects:

declare
   O : T;
begin
   write (addr => O'Address, nbytes => O'Size_In_Storage_Elements);
end;

instead of

declare
   O : T;
begin
   write (addr => O'Address, nbytes => O'Size / 8);
end;

(Of course, T is a first-named subtype whose size is an integral multiple
of System.Storage_Unit.  And in this case, System.Storage_Unit = 8.)

Matt

--------------------------------------------------------------------
Matthew Heaney
Software Development Consultant
<mailto:matthew_heaney@acm.org>
(818) 985-1271




  parent reply	other threads:[~1997-03-16  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-07  0:00 Packed array size question Marc Bejerano
1997-03-07  0:00 ` Robert Dewar
1997-03-13  0:00   ` Matthew Heaney
     [not found]     ` <01bc300c$247f6200$0e096dce@my-pc.neosoft.com>
1997-03-15  0:00       ` Robert Dewar
1997-03-16  0:00       ` Matthew Heaney [this message]
1997-03-16  0:00         ` Robert Dewar
1997-03-19  0:00           ` Dale Stanbrough
1997-03-21  0:00             ` Robert Dewar
replies disabled

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