<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-04-12 18:35 GMT+02:00 Bert Freudenberg <span dir="ltr"><<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On 12.04.2016, at 11:10, Tobias Pape <<a href="mailto:Das.Linux@gmx.de">Das.Linux@gmx.de</a>> wrote:<br>
><br>
><br>
> On 12.04.2016, at 08:38, marcel.taeumel <<a href="mailto:Marcel.Taeumel@hpi.de">Marcel.Taeumel@hpi.de</a>> wrote:<br>
><br>
>> Hi Tobias,<br>
>><br>
>> this version is made for endless streams, not the ones the always operate on<br>
>> a collection but sockets etc. So, the generator never ends and hence #atEnd<br>
>> is never true. I thought that #upToNil might be sufficient and also<br>
>> practical for other streams.<br>
>><br>
>> Best,<br>
>> Marcel<br>
><br>
><br>
> Sounds reasonable :)<br>
<br>
</span>Actually, no, it does not ;)<br>
<br>
If the stream hasn’t ended, the generator should continue. If the stream is at end, the generator should stop.<br>
<br>
We don’t need #upToNil, you just need to stop the generator when the stream ends:<br>
<br>
select: block<br>
^ Generator on: [:g |<br>
[self atEnd] whileFalse: [<br>
| object |<br>
object := self next.<br>
(block value: object) ifTrue: [g yield: object]]]<br>
<br>
... and similarly for the other methods. With that change, #upToEnd works just fine on the generator.<br>
<br>
Agreed? :)<br>
<span class="HOEnZb"><font color="#888888"><br>
- Bert -<br>
<br>
<br></font></span></blockquote><div>+1,<br>what's so special about nil?<br>For me upToNil is just upTo: nil <br></div></div><br></div><div class="gmail_extra">Nicolas<br></div></div>