#select:thenDo: in Squeak

Comments

If #select:thenDo: were optimized to not call #select, subclasses of Collection which re-implement #select (e.g. Dictionary) would also have to re-implement #select:thenDo: accordingly.

I'm going to keep dreaming of the day that the VM is smart enough to know when it's right to call the optimized #select:thenDo: code.... Hey, it could happen!
[this is good]
@Tom: you could implement #select: in terms of #select:thenDo:, so that anything special Dictionary had to do would go there rather than in #select:. If people used #select:thenDo: enough this would probably be a net performance gain, though I suspect they don't.
Hi

I took a look around at Dolphin, VisualWorks, Stongtalk, SmalltalkMT and Smalltalk/X for what they do. Pretty much none of them have a similar method except for Smalltalk/X which implements it exactly like you have suggested...

select:selectBlock thenDo:doBlock
[this is good]
Hi

sorry about previous post... something went wrong with the formatting...
Anyway as I was saying Smalltalk/X does implement it exactly as you have suggested and since it implements it in terms of #do: then Disctionary will take advantage of this optimisation.
[isto é bom]
Another thing though is that we are changing the method behaviour as the return value is now the receiver (using th optimized code) while the original code would return the elements that were selected in the enumeration.

This may break certain clients...??

Post a comment

Already a Vox member? Sign in

Randal Schwartz

About Me

Randal Schwartz
United States
Just another [insert technology here] hacker!
Jaiku:
merlyn

My Groups

Neighborhood

Explore friends, family, friends & family, or entire neighborhood.

Archives