comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <Nick.Roberts@dial.pipex.com>
Subject: Re: FORTRAN's Equivalence
Date: 1997/03/26
Date: 1997-03-26T00:00:00+00:00	[thread overview]
Message-ID: <01bc3a3b$ad32cb80$63f482c1@xhv46.dial.pipex.com> (raw)
In-Reply-To: 333840D1.7B12@cae.ca




Viqar Abbasi <viqar@cae.ca> wrote in article <333840D1.7B12@cae.ca>...

> I have a BIT_PATTERN : System.Unsigned_32.  The first 4 bits represent 
> an integer A, the next 17 represent another record B, the last eleven 
> represent an integer C.  Ada gives something beautiful, in the "use at" 
> clause, which lets me define a record to superimpose onto the bit 
> pattern.  

Robert Duff (circa this thread) is right, in that you should use the for
X'Address clause preferred in Ada 95.

> The big problem with this approach is that it isn't 
> guaranteed by the LRM, and I need my application to be portable to 
> other Ada implementations.  The Ada Quality and Style Guide, Clause 
> 5.9.4, also tells us that we should not use the "use at" clause to do 
> such things.  I am using the GNAT compiler, 3.07 on the SGI.  The final 
> system will be delivered for a VAX.
> 
> I have started doing my mapping via "Unchecked Conversions".  This seems 
> to be going well, as long as I take care of the VAX/SGI bit-pattern 
> differences.  Would using Unchecked_Conversions, when the sizes are 
> always the same, be considered 100% portable, and will work under any 
> ADA implementation?

You should not use Unchecked_Conversion, you should use the method you
suggested above. Don't worry about whether the technique you use is
portable or not. It will not be, and does not need to be. All you need to
do is to ISOLATE the non-portable bit (in a subprogram or package). Ensure
that the interface to this module is well defined. Then, all you have to do
to port to a new compiler or target is to change the isolated module.
Everything else remains untouched, and (provided the tenets of the
interface are not violated) its operation remains guaranteed.

> Furthermore, are any of you aware of a better way to map variables on 
> top of each other?  Please consider in any reply that I have extremely 
> tight speed requirements as well.

Why do you need to do this? There may well be a better way to achieve
whatever you need to do.

Hope this helps. Nick.






  parent reply	other threads:[~1997-03-26  0:00 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-03-25  0:00 Fortran's Equivalence Viqar Abbasi
1997-03-26  0:00 ` Robert Dewar
1997-03-26  0:00   ` Robert A Duff
1997-03-29  0:00   ` Matthew Heaney
1997-03-29  0:00     ` Robert Dewar
1997-04-02  0:00       ` JP Thornley
1997-03-26  0:00 ` Nick Roberts [this message]
1997-03-26  0:00 ` Michael F Brenner
1997-03-26  0:00   ` Larry Kilgallen
1997-03-28  0:00   ` Oliver Kellogg
1997-03-29  0:00   ` Matthew Heaney
1997-03-29  0:00     ` Robert Dewar
1997-03-29  0:00     ` Robert Dewar
1997-04-01  0:00       ` Keith Thompson
1997-04-01  0:00         ` Robert Dewar
1997-04-01  0:00           ` Robert A Duff
1997-04-01  0:00             ` Robert Dewar
1997-04-04  0:00           ` Keith Thompson
1997-04-04  0:00             ` Keith Thompson
1997-04-04  0:00               ` Robert Dewar
1997-04-08  0:00                 ` Keith Thompson
1997-04-04  0:00             ` Robert Dewar
1997-04-07  0:00               ` Viqar Abbasi
1997-04-08  0:00                 ` Charles H. Sampson
1997-04-08  0:00                   ` Robert Dewar
     [not found]                     ` <1997Apr15.163103.27481@nosc.mil>
1997-04-16  0:00                       ` Robert Dewar
1997-04-08  0:00                   ` Matthew Heaney
1997-04-09  0:00                     ` Stephen Leake
1997-04-09  0:00                       ` Robert Dewar
1997-04-10  0:00                         ` Simon Wright
1997-04-10  0:00                           ` Robert Dewar
1997-04-07  0:00               ` Keith Thompson
1997-04-07  0:00               ` Charles H. Sampson
1997-04-07  0:00             ` Charles H. Sampson
1997-03-26  0:00 ` Tom Moran
1997-03-28  0:00 ` Charles H. Sampson
1997-03-29  0:00   ` Matthew Heaney
1997-04-01  0:00     ` Charles H. Sampson
1997-03-29  0:00 ` Matthew Heaney
1997-03-29  0:00   ` Robert Dewar
replies disabled

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