comp.lang.ada
 help / color / mirror / Atom feed
From: Mark A Biggar <mark.a.biggar@lmco.com>
Subject: Re: An alternative to Unchecked Conversion
Date: 1999/12/16
Date: 1999-12-16T00:00:00+00:00	[thread overview]
Message-ID: <38595FAE.C04A77E8@lmco.com> (raw)
In-Reply-To: OF2D01D779.211C774B-ON88256849.006FEEEF@ray.ca

Tom_Hargraves@Raytheon.com wrote:
> 
> Related to "Questions about Unchecked_Conversion".
> 
> There have been some good responses to the related topic. I agree with the
> sentiment that Unchecked_Conversion should be rarely if ever used. However if
> you HAVE TO use it, it does come with an overhead. It is a routine which has to
> be called, and it may end up copying data around and cost you cpu time.

Most compilers implement Unchecked_Conversion as an implisit inlined routine
with no more (actually less as there are no checks done) overhead then
an assignment statement.
 
> So when you HAVE TO, e.g. to copy Ada structures onto byte streams being
> transmitted over a 'hardware' interface, there's another technique which has
> been around for a while. In the fortran era it was implemented using the common
> block and equivalence statements.
> 
> The technique is simply to map the Ada structure directly onto the 'other' data
> structure.
> 
> It has the following advantages:
> 1. It's fast, there is no data transfer 'cost'.
> 2. The data structures can be different sizes.
> 
> It has the following disadvantages:
> 1. If your Ada structure contains constrained types, then a write to the
> 'other' data structure can subsequently cause a constraint error when you come
> to read the data.
> 2. Timing and synchronisation become a issue if the reader and writer are not
> in the same task/thread.

3. There is no guarentee in the LRM that it will work correctly (although
most implementations will "Do The Right Thing").  So it definitely not
protable, while Unchecked_conversion is Guarenteed to be.

--
Mark Biggar
mark.a.biggar@lmco.com




      parent reply	other threads:[~1999-12-16  0:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-16  0:00 An alternative to Unchecked Conversion Tom_Hargraves
1999-12-16  0:00 ` Jeff Creem
1999-12-16  0:00 ` Matthew Heaney
1999-12-16  0:00   ` Richard D Riehle
1999-12-17  0:00     ` Ted Dennison
1999-12-17  0:00       ` Richard D Riehle
1999-12-16  0:00   ` Tom Hargraves
1999-12-16  0:00     ` DuckE
1999-12-16  0:00     ` Matthew Heaney
1999-12-17  0:00       ` Lutz Donnerhacke
1999-12-17  0:00         ` Matthew Heaney
     [not found]     ` <mhrj5s4qckk7rt1j3pu0s3r438e281pu37@4ax.com>
1999-12-17  0:00       ` Simon Wright
     [not found]         ` <g9rr5s84eeov4vvp2v9v70jo9b5uporm0v@4ax.com>
1999-12-20  0:00           ` Simon Wright
1999-12-23  0:00             ` Robert Dewar
1999-12-18  0:00       ` Rex Reges
1999-12-18  0:00         ` Matthew Heaney
1999-12-19  0:00         ` Robert Dewar
1999-12-20  0:00     ` Charles H. Sampson
1999-12-16  0:00 ` Mark A Biggar [this message]
replies disabled

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