comp.lang.ada
 help / color / mirror / Atom feed
From: stt@spock.camb.inmet.com (Tucker Taft)
Subject: Re: Size Rep clauses on Ada83 vs. Ada95
Date: 1995/03/29
Date: 1995-03-29T00:00:00+00:00	[thread overview]
Message-ID: <D67LCH.Iso@inmet.camb.inmet.com> (raw)
In-Reply-To: BPRIEST.95Mar28110812@ti.com

Bill Priest (bpriest@ti.com) wrote:

: Per 13.2 of Ada Programming Language Reference Manual (MIL-STD-1815a-1983)

: " Size specification:  T'SIZE

: The expression must be a static expression of some integer type.  The value
: of the expression specifies an upper bound for the number of bits to be 
: allocated to objects of the type or first named subtype T.  

This last sentence was effectively overruled by AI-536, even before 
Ada 9X hit the scene.  The official "Ada 83+AIs" rule is now 
that a size clause specifies a *lower* bound for the number of 
bits to be allocated to objects of the subtype T.  
This was for good reason, since the 'size for Standard.Boolean 
was also specified to be 1 by the same AI, but we all
know that it is desirable to give a stand-alone Boolean variable
at least a byte on most machines, and probably a whole word on many
RISC machines.

Since the early days of Ada, there has been a fair amount of disagreement
about the proper interpretation of the size clause.  Hence, if you
want to really control the representation of a record, use a record
representation clause, rather than relying on size clauses to do your
"dirty" work.

We have tried to clarify things a bit in Ada 95, but there is still
some controversy about whether a subtype size clause should have a direct
effect on stand-alone objects, if the specified size is "relatively"
efficient to use.  The final Ada 95 reference manual says:

   If the Size of a subtype is specified, and allows for efficient 
   independent addressibility on the target architecture, then the
   Size of the folllowing objects of the subtype should equal the
   Size of the subtype:
     - Aliased objects (including components)
     - Unaliased components, unless the Size of the component is determined
       by a component_clause or Component_Size clause.

We believe this wording corresponds pretty closely to the intent
of "Ada 83 + AIs," if you ignore the mention of "aliased" (which isn't
trivial to do ;-), though well-informed people still differ a bit on that...

Hence, the recommendation still stands that to be in complete
control, use a record representation clause.  Note also that
the word "should" rather than "shall" appears in the above citation 
from RM95, whereas in the rules on record representation clauses, there 
is no such implementation variability allowed.

: Bill

-Tucker Taft  stt@inmet.com
Intermetrics, Inc.




  reply	other threads:[~1995-03-29  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-28 17:08 Size Rep clauses on Ada83 vs. Ada95 Bill Priest
1995-03-29  0:00 ` Tucker Taft [this message]
1995-03-30  0:00   ` Bill Priest
replies disabled

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