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.9 required=5.0 tests=BAYES_00 autolearn=ham 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 12:48:25 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newshub2.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Ada.Streams.Read Length Paramenter is not IN? References: X-Newsreader: Tom's custom newsreader Message-ID: Date: Tue, 07 Aug 2001 19:48:24 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 997213704 24.7.82.199 (Tue, 07 Aug 2001 12:48:24 PDT) NNTP-Posting-Date: Tue, 07 Aug 2001 12:48:24 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:11521 Date: 2001-08-07T19:48:24+00:00 List-Id: > Ada.Streams.Read Length Parameter is not IN? Because Item'length tells how much data is wanted. Last tells you, as output, how much you actually got. If you have a situation where Last < Item'last does *not* mean EOF, but just means "that's all for now", then you can use a loop to keep trying until it's all there. Next : Stream_Element_Offset := Item'first; ... while Next <= Item'last loop Read(F, Item(Next .. Item'last), Last); Next := Last+1; end loop; > OTOH each T'Read or T'Input procedure exactly knows how many > Storage_Elements are needed to fulfill the request. Why is this information > not given to the Stream.Read procedure? It is. Any time you pass as array as a parameter you implicitly are also passing its 'first, 'last, 'length. > procedure Read( > Stream : in out Filedescriptor_Stream_Type; > Item : out Stream_Element_Array; > Last : out Stream_Element_Offset) is > begin > Item := Read (Stream); > Last := Item'Last; > end Read; This is unlikely to work. Since your Read (Stream) always returns an array of one element, assigning that to Item will only work if Item is an array of one element. The length of a particular Stream_Element_Array is not dynamic. That's why Last is there - so you can see the length of the actual useful data portion of Item.