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

Eliot Miranda eliot.miranda at gmail.com
Wed Apr 13 13:35:53 UTC 2016



> On Apr 12, 2016, at 1:19 PM, Bert Freudenberg <bert at freudenbergs.de> wrote:
> 
>> 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 -

+1


More information about the Squeak-dev mailing list