[squeak-dev] Re: Generators in Smalltalk?

Lukas Renggli renggli at gmail.com
Wed Feb 10 08:22:17 UTC 2010

On 10 February 2010 08:49, Andreas Raab <andreas.raab at gmx.de> wrote:
> Lukas Renggli wrote:
>> http://source.lukas-renggli.ch/continuations/Generator-lr.3.mcz
> Interesting, thanks. I notice you have Generator>>reset and Generator>>fork
> which are definitely useful, but no Generator>>close? The latter allowing to
> execute any unwind blocks associated with the generator, say:
> gen := Generator on:[:yield| | fs |
>        [fs := FileStream readOnlyFileNamed: 'foo.bar'.
>        [fs atEnd] whileFalse:[yield value: fs nextLine]]
>                ensure:[fs close]
> ].
> Unless a close operation is provided, the file in the above will not be
> closed properly.

I've fixed that. There could be more bugs, as I've never used them
beyond the anecdotical examples showing off runtime reflection. I
never saw a practical use of Generators in Smalltalk.


Lukas Renggli

More information about the Squeak-dev mailing list