From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 18 Aug 93 12:50:53 GMT From: 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@ucbvax.Berkeley.EDU (Robert Firth) Subject: Re: Data Overlays Message-ID: <1993Aug18.085053.940@sei.cmu.edu> List-Id: In article <1993Aug18.003940.2208@leeweyr.sccsi.com> bill@leeweyr.sccsi.com (Bi ll 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. 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.