comp.lang.ada
 help / color / mirror / Atom feed
From: "Pat Rogers" <progers@NOclasswideSPAM.com>
Subject: Re: 'Read for pointers
Date: 2000/07/26
Date: 2000-07-26T00:00:00+00:00	[thread overview]
Message-ID: <NHIf5.185$wE4.33424@nnrp3.sbc.net> (raw)
In-Reply-To: 8lndgv$1om$1@nnrp1.deja.com

"Ted Dennison" <dennison@telepath.com> wrote in message
news:8lndgv$1om$1@nnrp1.deja.com...
> I've seen it suggested in several places to handle Stream writing of
> pointers by writing what the pointer points to instead. That's
simple
> enough.
>
> But say I want to make this automatic. Lets say I have a pointer
type
> declared thusly:
>
> package Example is
>    type Handle is private;
>
>    ...
> private
>
>    type Instance;
>
>    type Handle is access all Instance;
>
> end Example;
>
> The user doesn't even really know or care that Handle is really a
> pointer. But they may need to do stream I/O with it.
>
> The obvious solution is to create my own 'Write and 'Read routines
for
> Handle. But there's a problem. Following is the profile for 'Read:
>
>    procedure Read
>      (Stream : access Ada.Streams.Root_Stream_Type'Class;
>       Item   : out    Handle
>      );
>    for Handle'Read use Read;
>
> The problem is that Item is an *out* parameter. That means I won't
have
> acces to the pointer's old value inside Read. There's no way I can
put
> the newly read data from the stream into the Instance that Handle
> currently points to!

You can read mode out parameters in Ada 95 (unlike Ada 83).  (Am I
missing something?)

--
Pat Rogers                            Consulting and Training in:
http://www.classwide.com      Deadline Schedulability Analysis
progers@classwide.com        Software Fault Tolerance
(281)648-3165                       Real-Time/OO Languages

Adam ... does not deserve all the credit; much is due to Eve, the
first woman, and Satan, the first consultant.
Mark Twain






  parent reply	other threads:[~2000-07-26  0:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-26  0:00 'Read for pointers Ted Dennison
2000-07-26  0:00 ` Pat Rogers
2000-07-26  0:00   ` tmoran
2000-07-26  0:00     ` Pat Rogers
2000-07-27  0:00       ` tmoran
2000-07-26  0:00         ` Pat Rogers
2000-07-27  0:00   ` Ted Dennison
2000-07-27  0:00     ` Pat Rogers
2000-07-27  0:00       ` Ted Dennison
2000-07-27  0:00         ` Pat Rogers
2000-07-26  0:00 ` Pat Rogers [this message]
2000-07-28  0:00   ` Stephen Leake
2000-07-28  0:00     ` tmoran
2000-07-29  0:00     ` Pat Rogers
2000-07-31  0:00       ` Stephen Leake
2000-07-31  0:00         ` Robert A Duff
2000-07-31  0:00         ` Pat Rogers
2000-07-28  0:00 ` Stephen Leake
2000-07-31  0:00   ` Ted Dennison
replies disabled

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