[squeak-dev] Generators in Smalltalk?

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

Sorry for the late response.  My LazyLists package does that sort of
thing.  You wouldn't use yield though, I don't remember the syntax but
I think it's either very obvious or layed out in the tests.  If you
still need this and you can't figure out quickly from the package,
then let me know and I'll have a look.

On Wed, Feb 10, 2010 at 7:27 AM, Andreas Raab <andreas.raab at gmx.de> wrote:
> Folks -
> One thing I really like about Python is Generators
> (http://docs.python.org/tutorial/classes.html#generators). They allow code
> to provide a stream (iterator) interface where it's not easy to provide the
> interface explicitly. I.e., it would allow one to provide a stream interface
> to an arbitrary computation like:
> gen := Generator on: [:yield| 3 to: 1 by: -1 do:[:i| yield value: i]].
> gen next. "=>3"
> gen next. "=>2"
> gen next. "=>1"
> gen next. "=>nil"
> This *ought* to be really simple to do in Smalltalk by using blocks and some
> voodoo in the execution engine. Has anyone ever done that?
> Cheers,
>  - Andreas

More information about the Squeak-dev mailing list