[squeak-dev] Generator (was Re: The Trunk: System-ul.436.mcz)

Chris Muller asqueaker at gmail.com
Thu May 12 00:14:30 UTC 2011


On Wed, May 11, 2011 at 4:37 PM, Levente Uzonyi <leves at elte.hu> wrote:
> On Tue, 10 May 2011, Bert Freudenberg wrote:
>
>>
>> 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.
>
> Right, but it's a one trick pony. I don't think it would see much use.

Agree, and not only that, the Generator is mega-cool.



More information about the Squeak-dev mailing list