From: Anonymous Coward <spam@spam.com>
Subject: Re: Default rep specs for record types - documented??
Date: Mon, 14 Nov 2005 03:03:38 GMT
Date: 2005-11-14T03:03:38+00:00 [thread overview]
Message-ID: <slrndng6nf.b0.bogus_addy@tango.mindfuq.org> (raw)
In-Reply-To: wcc64qw821y.fsf@shell01.TheWorld.com
In article <wcc64qw821y.fsf@shell01.TheWorld.com>, Robert A Duff wrote:
> "Steve" <nospam_steved94@comcast.net> writes:
>
>> But if you add a representation clause:
>>
>> for Color'size use 8;
>>
>> All compilers will use the same number of bits to represent an instance of
>> color?
>
> No (unfortunately). It means "use at least 8 bits for objects".
> A compiler is free to allocate 32. To control the size of objects,
> you have to use 'Size on the object, or, if it's a component,
> a record rep clause or a 'Component_Size on an array.
I keep getting to a point where I think I've mastered these rep specs,
and yet more gotchas emerge. I had no idea I could control the
representation of objects independant of the representation of their
types.
I'm shocked to hear that size specs on types are merely a *minimum*.
Can I at least rely on pragma convention to guarantee an absolute size
on enums/integers?
As for records, I've imposed sizes on all my rep spec'd record types.
It would normally be needless, but to protect the maintainer from
accidentally defining a partial rep spec as the operational spec
grows, I've added a size spec so an error will be thrown at compile
time.
It seems your statement about size specs on types only being a minimum
does not apply to record types, correct? Here is some code that fails
to compile because the operational spec forces growth beyond that of
the size spec:
procedure Record_Experiment is
type Cuban_Aid_In_USD is range 0..50_000;
type Bushs_Record is record
Iraq_WoMD_Count : Natural;
Dead_Americans : Positive;
Dead_Civilians : Positive;
Deficit_In_Thousands : Integer;
Aid_Offered_To_Cuba : Cuban_Aid_In_USD;
end record;
for Bushs_Record use record
Iraq_WoMD_Count at 0 range 0..31;
Dead_Americans at 4 range 0..31;
Dead_Civilians at 8 range 0..31;
Deficit_In_Thousands at 12 range 0..31;
end record;
--The following line breaks the compile,
--which is expected and desirable.
--
for Bushs_Record'Size use 128;
President : Bushs_Record;
--The following line just illustrates that
--the object size spec can differ from the
--type size spec.
--
for President'Size use 160;
begin
null;
end Record_Experiment;
In this case, I added "Aid_Offered_To_Cuba" to the operational spec,
forcing the record to exceed 128 bytes, which causes an error. This
seems like the best protection, but it's still inadequite because a
neglectful maintainer can still increase the size spec without
completing the layout.
next prev parent reply other threads:[~2005-11-14 3:03 UTC|newest]
Thread overview: 60+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-04 2:21 Default rep specs for record types - documented?? Anonymous Coward
2005-11-04 2:36 ` Steve
2005-11-04 4:11 ` Anonymous Coward
2005-11-04 5:30 ` Jeffrey R. Carter
2005-11-05 3:13 ` Steve
2005-11-05 4:45 ` Jeffrey R. Carter
2005-11-06 14:05 ` Steve
2005-11-06 16:08 ` Anonymous Coward
2005-11-07 7:25 ` Jeffrey R. Carter
2005-11-08 13:36 ` Steve
2005-11-14 1:12 ` Robert A Duff
2005-11-14 3:03 ` Anonymous Coward [this message]
2005-11-14 18:08 ` Jeffrey R. Carter
2005-11-14 18:49 ` Robert A Duff
2005-11-15 1:16 ` ADA compilers can reject types arbitrarily? Anonymous Coward
2005-11-15 2:10 ` tmoran
2005-11-15 3:12 ` Robert A Duff
2005-11-15 6:44 ` Simon Wright
2005-11-16 0:16 ` Adaists Deny Acronym. (was: ADA compilers can reject types arbitrarily?) Björn Persson
2005-11-16 5:38 ` Adaists Deny Acronym Simon Wright
2005-11-16 6:16 ` Adaists Deny Acronym. (was: ADA compilers can reject types arbitrarily?) Samuel Tardieu
2005-11-15 12:43 ` ADA compilers can reject types arbitrarily? Jeff Creem
2005-11-14 21:14 ` Default rep specs for record types - documented?? Simon Wright
2005-11-04 13:26 ` Stephen Leake
2005-11-04 14:33 ` Marc A. Criley
2005-11-04 18:35 ` Georg Bauhaus
2005-11-04 20:07 ` Britt Snodgrass
2005-11-04 14:39 ` Stephen Leake
2005-11-04 15:27 ` Britt Snodgrass
2005-11-04 15:55 ` Lauri Ora
2005-11-04 21:42 ` Larry Kilgallen
2005-11-05 2:26 ` Anonymous Coward
2005-11-05 2:42 ` Frank J. Lhota
2005-11-05 3:27 ` Ed Falis
2005-11-05 3:55 ` Anonymous Coward
2005-11-05 4:07 ` Lauri Ora
2005-11-05 13:46 ` Ed Falis
2005-11-05 10:14 ` Stephen Leake
2005-11-04 16:52 ` Frank J. Lhota
2005-11-04 16:57 ` Frank J. Lhota
2005-11-04 23:27 ` tmoran
2005-11-05 10:25 ` Stephen Leake
2005-11-14 1:09 ` Robert A Duff
2005-11-05 3:33 ` Anonymous Coward
2005-11-05 10:34 ` Stephen Leake
2005-11-05 16:35 ` ADA/C interfaces: type representations uncontrollable in C Anonymous Coward
2005-11-05 16:49 ` Ed Falis
2005-11-05 18:24 ` tmoran
2005-11-09 2:12 ` 'Size can mean value size OR object size, depending Anonymous Coward
2005-11-09 3:27 ` Jeffrey R. Carter
2005-11-09 4:04 ` Anonymous Coward
2005-11-05 14:27 ` Default rep specs for record types - documented?? Michael Bode
2005-11-05 16:17 ` pragma convention Anonymous Coward
2005-11-06 1:07 ` Jeffrey R. Carter
2005-11-06 22:22 ` Anonymous Coward
2005-11-07 7:34 ` Jeffrey R. Carter
2005-11-05 14:39 ` Default rep specs for record types - documented?? Martin Krischik
2005-11-04 9:40 ` Martin Dowie
2005-11-04 14:36 ` Marc A. Criley
2005-11-04 17:45 ` Martin Krischik
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox