comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
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: <01bcb2f2$b512f700$928871a5@dhoos> (raw)
In-Reply-To: jeffrey.m.creem-2708970802350001@ljd155.sanders.lockheed.com


Just a couple of points, viz.:

  1.  The DEC Ada compiler for VAXen allowed biased rep clauses, as well.
       It's gratifying that gnat chose to implement this also.

  2.  The problem with your packed array example, however, is that what you
       are asking the compiler to do is to force array elements which are
smaller than
       one byte to straddle byte boundaries.  No compiler likes to do this,
as far as I
       know. (Record components straddling byte boundaries, are another
matter, and they
       are handled quite nicely without any ugly source code).
       Simply using pragma Pack instead of a "for 'size use 24" clause will
result in your
       8-element x 3-bit array occupying 32 bits, which is not bad at all.
       Undoubtedly, the extra code required to mask and shift the varying
amounts as
       a function of the array index would substantially exceed the one
byte of array
       size saved.  Besides, even if the compiler did give you your 24-bit
array, it would
       probably skip to the next 32-bit boundary for the next object in
memory, anyway.
       Even gnat will not give you a 24-bit array for this case (at least
the WinNT version 3.09).
       
David C. Hoos, Sr.       

Jeff Creem <jeffrey.m.creem@lmco.com> wrote in article
<jeffrey.m.creem-2708970802350001@ljd155.sanders.lockheed.com>...
> In article <dewar.872630607@merv>, dewar@merv.cs.nyu.edu (Robert Dewar)
wrote:
> 
> >Jeff says
> >
> 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 :)
> 
> The cool GNAT rep spec example that robert gave would also be nice but
> probably not required. If a compiler does not support the rep specs
> like in roberts example the code to work around it is pretty minor, if
> it does not support component sizes less than 8 and you really need
> them to interface to hardware, the code gets ugly very quickly and
> often starts to look like ugly C code.
> 
> 
> In any case GNAT handles everything I've ever wanted in a rep spec.. Too
> bad there is not a supported vxWorks port..
> 
> Jeff
> 




  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         ` David C. Hoos, Sr. [this message]
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-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
1997-09-08  0:00                         ` Robert A Duff
1997-09-08  0:00                           ` Matthew Heaney
1997-09-09  0:00                             ` Robert A Duff
1997-08-27  0:00           ` Robert Dewar
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-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