[squeak-dev] Re: Generators on Streams on Generators on Collections on ...

Eliot Miranda eliot.miranda at gmail.com
Wed Apr 13 13:40:37 UTC 2016


Dave,



> On Apr 12, 2016, at 1:47 PM, David T. Lewis <lewis at mail.msen.com> wrote:
> 
> FWIW, In OSProcess I used #upToEnd to mean "all of the data that is
> currently available in the stream" and #upToEndOfFile to mean "all of that
> data that will ever be available". Separately, the steam may be in
> blocking or non-blocking mode, where blocking means that #upToEndOfFile
> will block until EOF is detected.

I think this is a mistake and I hope you'll reconsider.  #atEnd is well-defined, as Bert's example for SocketStream showed.  If you choose to change the meaning in this one example you sow the seeds of confusion, and force people trying to use standard stream facilities (such as xstreams of generators) to implement exceptions to adapt to your alternative.  That way leads to brittle and hard-to-understand code.  Please change this.

> 
> Dave
> 
>>> On 12.04.2016, at 21:33, marcel.taeumel <Marcel.Taeumel at hpi.de> wrote:
>>> 
>>> Hi Nicolas,
>>> 
>>> if you construct something like:
>>> 
>>> | someStream |
>>> someStream := mySocketStream select: [:ea | ... ] thenCollect: [:ea |
>>> ... ].
>>> ...
>>> someStream next.
>>> ...
>>> someStream next: 5.
>>> ...
>>> 
>>> You can only use someStream as long as there is data available while it
>>> is
>>> connected. Now, it can happen that socket streams are temporarily "at
>>> end"
>>> while no data is waiting in the buffer. Then, you would have to
>>> reconstruct
>>> someStream to continue. And know about it.
>> 
>> AFAIK, “at end” means there will not be any more data:
>> 
>> SocketStream>>atEnd
>>    "There is nothing more to read when
>>    there is no more data in our inBuffer, the socket
>>    is disconnected and there is none available on the socket.
>>    Note that we need to check isConnected before isDataAvailable,
>>    otherwise data may sneak in in the meantime. But we check the
>>    buffer first, because it is faster.”
>> 
>>    self isInBufferEmpty ifFalse: [^false].
>>    ^self isConnected not
>>        and: [self isDataAvailable not]
>> 
>> 
>> - Bert -
> 
> 
> 


More information about the Squeak-dev mailing list