comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Ada 95 Numerics questions for the experts
Date: 1997/09/06
Date: 1997-09-06T00:00:00+00:00	[thread overview]
Message-ID: <dewar.873592294@merv> (raw)
In-Reply-To: EFxt94.F5F@world.std.com



Bob said

<<It depends what you're trying to do.  If you really care about the exact
size of the components (e.g. because you're interfacing to external
hardware or software), then use a Component_Size clause.  If you just
want to squeeze the thing down to a reasonably small size, because you
know that will be more efficient, then pragma Pack is more appropriate.

In the case mentioned here, where the components will fit in 1 bit, it
won't actually make any difference, that is:

>for arr8'Component_Size use 1;
>
>instead of
>
>pragma Pack (arr8);

both of the above will result in arr8'Component_Size = 1, and arr8'Size
= 8.>>


This is surpringly wrong. Bob, you must go read the RM, it was written
by this clever fellow Bob Duff, and will tell you the TRUTH :-) :-)


First, in the absence of implementation of annex C, neither declaration
will guarantee close packing.

In the presence of close packing, it is true that both will guarantee
this, but given the two declarations

    pragma Pack (array_type);
    for array_type'component_size use array_component_type'size;

it is never the case that, as suggested by Bob Duff's quote, that the
second form is somehow more exact than the first. I find this odd, but
then I did not write the RM!

There are two issues to consider

1. Is annex C implemented? If not, then either of these declarations on their
   own may have no effect. 

2. If annex C is implemented, then

   is the component size or size of the component a factor or multiple of
   the word size?

   if yes, then either of these two declarations will do the job

   if NOT, then pragma Pack is stronger because it will do no worse than
   go up to the next factor (e.g. 3 moved to 4), but a component size
   clause can be completely ignored, since there is no requirement to
   implement component clauses in this case (technically what you do
   is to accept the component claiuse, but then implement allowed gaps),

Note that using BOTH clauses together is useful, since in this case, the RM
guarantees that a compiler that accepts the clauses, even if it does not
implment Annex C, MUSt do the right thing.

Odd eh?





  parent reply	other threads:[~1997-09-06  0:00 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3401C14B.480@gsfc.nasa.gov>
1997-08-25  0:00 ` Ada 95 Numerics questions for the experts Robert Dewar
     [not found] ` <dewar.872560585@merv>
     [not found]   ` <jcreem-2608970711210001@ljd155.sanders.lockheed.com>
     [not found]     ` <dewar.872630607@merv>
     [not found]       ` <jeffrey.m.creem-2708970802350001@ljd155.sanders.lockheed.com>
1997-08-27  0:00         ` Robert Dewar
     [not found]           ` <jeffrey.m.creem-2808970708260001@ljd155.sanders.lockheed.com>
1997-08-28  0:00             ` Robert Dewar
1997-08-27  0:00         ` David C. Hoos, Sr.
1997-08-27  0:00           ` Robert Dewar
1997-08-27  0:00           ` Jeff Creem
1997-08-28  0:00             ` Robert Dewar
1997-08-28  0:00               ` Jeff Creem
1997-08-29  0:00               ` Tucker Taft
1997-08-30  0:00                 ` Robert A Duff
1997-08-31  0:00                 ` Tom Moran
1997-09-01  0:00                 ` Robert Dewar
1997-09-02  0:00                   ` Fergus Henderson
1997-09-02  0:00                   ` Robert A Duff
     [not found]                   ` <mheaney-ya023680000209972104030001@news.ni.net>
1997-09-05  0:00                     ` Robert Dewar
1997-09-05  0:00                       ` Matthew Heaney
1997-09-08  0:00                         ` Robert A Duff
1997-09-08  0:00                           ` Matthew Heaney
1997-09-09  0:00                             ` Robert A Duff
     [not found]                     ` <EFxt94.F5F@world.std.com>
1997-09-06  0:00                       ` Robert Dewar [this message]
1997-09-08  0:00                         ` Robert A Duff
1997-09-08  0:00                           ` Matthew Heaney
1997-09-09  0:00                             ` Robert A Duff
1997-09-01  0:00                 ` Robert Dewar
1997-08-30  0:00         ` Robert A Duff
replies disabled

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