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=0.6 required=5.0 tests=BAYES_00,TO_NO_BRKTS_FROM_MSSP autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6b7d31ee31aa032 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-07 11:39:41 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!feed.textport.net!newsranger.com!www.newsranger.com!not-for-mail Newsgroups: comp.lang.ada From: Ted Dennison References: Subject: Re: Ada.Streams.Read Length Paramenter is not IN? Message-ID: X-Abuse-Info: When contacting newsranger.com regarding abuse please X-Abuse-Info: forward the entire news article including headers or X-Abuse-Info: else we will not be able to process your request X-Complaints-To: abuse@newsranger.com NNTP-Posting-Date: Tue, 07 Aug 2001 14:39:29 EDT Organization: http://www.newsranger.com Date: Tue, 07 Aug 2001 18:39:29 GMT Xref: archiver1.google.com comp.lang.ada:11516 Date: 2001-08-07T18:39:29+00:00 List-Id: In article , Lutz Donnerhacke says... >procedure Read( > Stream : in out XXX_Stream_Type; > Item : out Stream_Element_Array; > Last : out Stream_Element_Offset); .. >OTOH each T'Read or T'Input procedure exactly knows how many >Storage_Elements are needed to fullfill the request. Why is this information >not given to the Stream.Read procedure? It is. That information is Item'length. One of the nifty things about Ada is that we don't need a separate parameter to specify how large a passed-in buffer is. You may protest that there's no guarantee that they won't give you a bigger buffer than they need, but the guarantee is implied. Think about it. If you gave back more data than they needed, what could they do with the extra? How would they get it back in the stream so it could go to the rightful owner? There's no way. So they will call you with the exact sized buffer for the data they want to read. >BTW: Do I understand the procedure semantics correctly, if I return Item and > Last := Item'Last generally. But in the case of EOF returning Item > larger than normally and set Item'Last to the last valid element. > Would it be not simpler to have the following procedure? The data returned couldn't be *larger*, (the buffer is only Item'Last long). It could be smaller due to EOF, in which case I'd expect either you to return Last < Item'Last, or you to raise an exception. I think Streams.Stream_IO raises END_ERROR. --- T.E.D. homepage - http://www.telepath.com/dennison/Ted/TED.html home email - mailto:dennison@telepath.com