[squeak-dev] Generator (was Re: The Trunk: System-ul.436.mcz)
Bert Freudenberg
bert at freudenbergs.de
Tue May 10 11:58:37 UTC 2011
On 10.05.2011, at 06:55, Levente Uzonyi wrote:
> On Mon, 9 May 2011, Chris Muller wrote:
>
>> Uh oh, lookout! Levente is pulling out the Generator!! :-)
>
> I thought it's time to use it from a real method (one that's not a test for Generator). Btw it's not worth to use it there performance wise compared to creating a collection of the Behaviors, but it doesn't matter in this piece of code.
For this use case it might be nice to have something simpler than a Generator. Instead of
Generator on: [ :generator |
self allBehaviorsDo: [ :each |
generator yield: each ] ])
we might want to write
CollectionMaker on: [:workBlock | self allBehaviorsDo: workBlock]
CollectionMaker>>do: aBlock
^doBlock value: aBlock
This would be much less tricky than Generator, because no coroutines are needed in this case.
- Bert -
More information about the Squeak-dev
mailing list
|