comp.lang.ada
 help / color / mirror / Atom feed
From: alex@MIMSY.CS.UMD.EDU  (Alex Blakemore)
Subject: Re: Data Overlays
Date: 23 Aug 93 14:11:03 GMT	[thread overview]
Message-ID: <70605@mimsy.umd.edu> (raw)

In article <1993Aug19.185126.27655@iplmail.orl.mmc.com> rgilbert@orl.mmc.com wr
ites:
>   Method 3 : Use Unchecked_Conversion to pass (by reference) a parameter to a
 procedure
>                 procedure Overlay(Y : in out TYPE_2) is
>                 function To_Type_2 is new Unchecked_Conversion(TYPE_1, TYPE_2
);
>                   Overlay(To_Type_2(X));  -- Now reference to object as other
 type
>               The advantages are: ....

The disadvantages are ... it doesnt compile, its not legal Ada
you cant use a function result as an actual parameter of mode in out.
ut I believe it should work.
no comment :-)

in my opinion, its ok to use an overlay if it works to solve your problem
and there is no other way without copying a large buffer.
just isolate it, document it, and dont expect it to port.

the one case where I found it necessary was trying to read into a large
string buffer using Posix IO (which defines its own string type)
the only portable solution was to read into a posix string, and then
use the posix conversion function to convert between the two (really identical)
string types.

so in that case, there were only two choices
a. copy each IO buffer an additional time just to change its type, (but not its
 representation)
   + portable
   - wasteful
b. use an overlay to allow reading with posix string type and access with Ada s
tring type
   + efficient
   - perhaps not portable

since the buffers were large, and IO performance was a major concern and changi
ng
the posix interface (or the rest of the application) were out of the question,
I think using an overlay was the right choice.

of course, it would be a lot easier if the posix interface used standard.string
,
but I suppose there are still a few EBCDIC machines somewhere
-- 
Alex Blakemore       alex@cs.umd.edu        NeXT mail accepted
--------------------------------------------------------------
"Without an engaged and motivated human being at the keyboard,
the computer is just another dumb box."      William Raspberry

             reply	other threads:[~1993-08-23 14:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1993-08-23 14:11 Alex Blakemore [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-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 16:04 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