From: "Pat Rogers" <progers@NOclasswideSPAM.com>
Subject: Re: 'Read for pointers
Date: 2000/07/31
Date: 2000-07-31T00:00:00+00:00 [thread overview]
Message-ID: <boih5.80$5l3.11275@nnrp2.sbc.net> (raw)
In-Reply-To: uem4awakr.fsf@gsfc.nasa.gov
"Stephen Leake" <stephen.a.leake.1@gsfc.nasa.gov> wrote in message
news:uem4awakr.fsf@gsfc.nasa.gov...
> "Pat Rogers" <progers@NOclasswideSPAM.com> writes:
>
> > "Stephen Leake" <stephen.a.leake.1@gsfc.nasa.gov> wrote in message
> > news:uaef1lxlw.fsf@gsfc.nasa.gov...
> > > Suppose the user writes:
> > >
> > > My_Handle : Handle;
> > >
> > > (somehow, My_Handle is given some value)
> > >
> > > Read (Stream, My_Handle);
> > >
> > > The value of My_Handle is _not_ copied to Item at the procedure
> > call.
> > > That only happens for "in" or "in out" parameters, not "out"
> > > parameters.
> >
> > Have a look at RM 6.4.1{12,13} for a surprise.
>
> I stand corrected. I guess the Ada designers were trying to prevent
> garbage pointers.
That's what the AARM indicates.
> I think I'd prefer the standard "initialized to
> null" behavior here, for consistency.
>
> I guess it's easy enough to remember that "out" is the same as "in
> out" for access types, and composite types with discriminants.
>
> On further thought, I can't think of a time when this behavior is
> actively bad; it's just not what I thought the rules were.
There is, however, an interesting side issue from the part of RM
6.4.1{13} that says no constraint check is done on the incoming value.
Keith Thompson (no, the other Keith:) submitted a question and this
bit of code that led to AI95-00110:
with Ada.Text_IO; use Ada.Text_IO;
procedure Foo is
type Pointer is access String;
P: Pointer := new String'("hello");
subtype Pointer_10 is Pointer(1 .. 10);
procedure Proc(Param: out Pointer_10) is
begin
Put_Line("Param'Length = " & Integer'Image(Param'Length));
end Proc;
begin
Proc(P);
end Foo;
Param'Length is clearly 5, which violates the constraint but is not
checked. (Evaluation of the attribute is another matter.) The AI is
pretty interesting reading (but then I thought the Implementer's Guide
was interesting too:).
--
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
next prev parent reply other threads:[~2000-07-31 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-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 [this message]
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-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