comp.lang.ada
 help / color / mirror / Atom feed
From: sampson@cod.nosc.mil  (Charles H. Sampson)
Subject: Re: Data Overlays
Date: 18 Aug 93 16:04:38 GMT	[thread overview]
Message-ID: <1993Aug18.160438.9171@nosc.mil> (raw)

In article <1993Aug18.085053.940@sei.cmu.edu> firth@sei.cmu.edu (Robert Firth) 
writes:
|>In article <1993Aug18.003940.2208@leeweyr.sccsi.com> bill@leeweyr.sccsi.com (
Bill Lee) writes:
|>
|>>function Extract_Message ( A_Message : in Byte_Arrays ) return Messages is
|>>  Temp_Message : Messages;
|>>  for Temp_Message use at A_Message'address;
|>>begin
|>>  return Temp_Message;
|>>end Extract_Message;
|>
|>As one who, when writing a compiler many years ago, took great pains to
|>ensure that this construct would work, I can sympathise with the above.
|>
|>It is formally incorrect, but as far as I can see should work in all
|>reasonable circumstances, regardless of whether the parameters are
|>passed by value or by reference.  Of course, some compilers will
|>screw up when handling the return value, but that's their problem.

     No it's not.  The program is erroneous and compiler writers are
not required to spend time making it "work right".

|>However, be warned that this approach might be a lot less efficient
|>than necessary - you could have upto two copies of the data in the
|>byte array.  That's the main reason I prefer to solve a problem such
|>as this by means of Unchecked_Conversion on addresses - I know that
|>there is no unnecessary copying; I'm keeping the data in the buffer
|>and simply looking at it through new spectacles, as it were.

     Certainly the technique I prefer.

				Charlie

             reply	other threads:[~1993-08-18 16:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-08-18 16:04 Charles H. Sampson [this message]
  -- strict thread matches above, loose matches on Subject: below --
1993-09-01 14:36 Data Overlays David Emery
1993-09-01  4:23 Jim Lonjers
1993-08-31 20:36 dog.ee.lbl.gov!agate!howland.reston.ans.net!math.ohio-state.edu!magnus.ac
1993-08-31  3:51 Jim Lonjers
1993-08-23 14:17 Bob Crispen
1993-08-23 14:11 Alex Blakemore
1993-08-19 13:16 cs.utexas.edu!mars.tsd.arlut.utexas.edu!gardner
1993-08-19  2:18 portal!cup.portal.com!R_Tim_Coslet
1993-08-18 16:40 cis.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news.den.mmc.com!iplmail
1993-08-18 16:27 Charles H. Sampson
1993-08-18 12:55 cis.ohio-state.edu!magnus.acs.ohio-state.edu!csn!news.den.mmc.com!iplmail
1993-08-18 12:50 cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!europa.eng.gtefsd.com!fs7.ece.cmu.edu!news.sei.cmu.edu!firth
1993-08-18  2:11 cis.ohio-state.edu!magnus.acs.ohio-state.edu!usenet.ins.cwru.edu!agate!do
1993-08-18  1:53 cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!howland.
1993-08-18  0:39 cis.ohio-state.edu!magnus.acs.ohio-state.edu!math.ohio-state.edu!cs.utexa
1993-08-17 15:16 Charles H. Sampson
1993-08-13 17:57 cgl!sgiblab!darwin.sura.net!mlb.semi.harris.com!x102a!scook
1993-08-13 12:48 Bob Gilbert
replies disabled

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