[squeak-dev] Re: Generators in Smalltalk?

Jason Johnson jason.johnson.081 at gmail.com
Mon Mar 29 05:48:37 UTC 2010

On second thought, I guess there must be some kind of yield.

In any case, I wrote my LazyList package to implement the iCal spec.
I use it to do complex things like allowing the user to specify one or
more date generators (infinite list of e.g. Thursdays) and filter
based on one or more other infinite sets (e.g. my families birthdays).
 Since the generated dates will be in order this works fine.

On Wed, Feb 10, 2010 at 9:03 AM, Andreas Raab <andreas.raab at gmx.de> wrote:
> Colin Putney wrote:
>> Also, Stephen Pair posted an implementation here in December:
>> http://n4.nabble.com/ANN-CoroutineReadStream-tt963004.html#a963004
> Brilliant! That's the ticket! Once I got down the right path it's even
> simpler than that. I put a version of Generator into the inbox for people to
> play with and give feedback. With 5 methods total you get to do fun stuff
> like:
> | gen max |
> max := 10000000.
> gen := Generator on:[:yield| Integer primesUpTo: max do: yield].
> 'Computing primes' displayProgressAt: Sensor cursorPoint
>        from: 1 to: max during:[:bar| | prime |
>                [prime := gen next] whileNotNil:[bar value: prime].
>        ].
> I think we should add support for Generators. They are so incredibly useful
> where you have complex operations that you don't want to spend the upfront
> effort on to compute everything (like primes) before you can do some work
> with the results.
> Cheers,
>  - Andreas

More information about the Squeak-dev mailing list