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

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Tue Apr 12 17:23:44 UTC 2016


2016-04-12 18:35 GMT+02:00 Bert Freudenberg <bert at freudenbergs.de>:

>
> > On 12.04.2016, at 11:10, Tobias Pape <Das.Linux at gmx.de> wrote:
> >
> >
> > On 12.04.2016, at 08:38, marcel.taeumel <Marcel.Taeumel at hpi.de> wrote:
> >
> >> Hi Tobias,
> >>
> >> this version is made for endless streams, not the ones the always
> operate on
> >> a collection but sockets etc. So, the generator never ends and hence
> #atEnd
> >> is never true. I thought that #upToNil might be sufficient and also
> >> practical for other streams.
> >>
> >> Best,
> >> Marcel
> >
> >
> > Sounds reasonable :)
>
> Actually, no, it does not ;)
>
> If the stream hasn’t ended, the generator should continue. If the stream
> is at end, the generator should stop.
>
> We don’t need #upToNil, you just need to stop the generator when the
> stream ends:
>
> select: block
>         ^ Generator on: [:g |
>                 [self atEnd] whileFalse: [
>                         | object |
>                         object := self next.
>                         (block value: object) ifTrue: [g yield: object]]]
>
> ... and similarly for the other methods. With that change, #upToEnd works
> just fine on the generator.
>
> Agreed? :)
>
> - Bert -
>
>
> +1,
what's so special about nil?
For me upToNil is just upTo: nil

Nicolas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20160412/ddc89843/attachment.htm


More information about the Squeak-dev mailing list