From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,573be8c453ecbff4 X-Google-Attributes: gid103376,public From: "Pat Rogers" Subject: Re: 'Read for pointers Date: 2000/07/31 Message-ID: #1/1 X-Deja-AN: 652856380 References: <8lndgv$1om$1@nnrp1.deja.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.3018.1300 X-Complaints-To: abuse@swbell.net X-Trace: nnrp2.sbc.net 965063303 208.191.184.67 (Mon, 31 Jul 2000 12:08:23 CDT) Organization: SBC Internet Services X-MSMail-Priority: Normal NNTP-Posting-Date: Mon, 31 Jul 2000 12:08:23 CDT Newsgroups: comp.lang.ada Date: 2000-07-31T00:00:00+00:00 List-Id: "Stephen Leake" wrote in message news:uem4awakr.fsf@gsfc.nasa.gov... > "Pat Rogers" writes: > > > "Stephen Leake" 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