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/08/27
Date: 1997-08-27T00:00:00+00:00	[thread overview]
Message-ID: <dewar.872715585@merv> (raw)
In-Reply-To: jeffrey.m.creem-2708970802350001@ljd155.sanders.lockheed.com


Jeff says

<<GNATs ability to handle rep specs like your example is actually very cool
and the first compiler I know of that handles this type of case. The AdaMajic
front end is even more limited than not allowing your cool example.
Even something like

type My_Type is range 0 .. 7;
for My_Type'size use 3;
type My_Array is array(1 .. 8) of M
for My_Array'size use 24;


Is not allowed because the element size of My_Arary is less than 8 it
rounds to 8 for each element.  This can be a real pain at times. While
I basically agree with the rational in the LRM for the minimum level of
support I think that if a compiler supports the systems programming annex that
rep specs like mine above should be required (of course I would think
that since it is something I wanted....I'm not biased :)>>



Actually DEC Ada 83 handles biased types (the reason we implemented it in
GNAT was for DEC Ada 83 conmpatibility).


Also, your example is wrong thinking. You cannot (more accurately should
not be able to) use a size clause to affect the internal layout of an
array. Obviously the default layout for MY_array would be expected to
use one byte/element.,

If you want the packed representation, you must use pragma Pack, and then
indeed GNAT will happily pack the 8 elements into 24 bits.

The relevant RM quote is RM 13.3(53)

53   A Size clause on a composite subtype should not affect the internal
layout of components.


GNAT follows this implementation advice. If it were not followed, you can
get surprising expensive change of representation conversions happening
behind your back as a result of type derivation.

It is a continuing problem that, despite similar advice in Ada 83 AI's,
some Ada 83 compilers, notably VADS, violate this implementation advice,
so oftem we have to tell people to add a pragma Pack.





  parent reply	other threads:[~1997-08-27  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 [this message]
     [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           ` 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                   ` Robert A Duff
1997-09-02  0:00                   ` Fergus Henderson
     [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
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-27  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