[squeak-dev] Collection's #fold: vs #reduce:
Eliot Miranda
eliot.miranda at gmail.com
Tue Nov 2 17:45:39 UTC 2010
Hi Levente,
On Tue, Nov 2, 2010 at 10:16 AM, Levente Uzonyi <leves at elte.hu> wrote:
> Hi,
>
> we have these two methods which do exactly the same thing. #reduce: was
> added by Andreas during the developement of Squeak 4.1. #fold was added by
> Eliot for Cog VMMaker compatibility. One of them is superfluous. I can image
> the following solutions:
>
> 1) Replace senders of #fold: in VMMaker to use #reduce:, and remove #fold:
> from the image.
>
> 2) Replace #fold:'s implementation to self reduce: aBlock. I benchmarked
> the two methods and #reduce: is a bit faster on CogVM. There's no difference
> on SqueakVM.
>
I noticed the same thing. I prefer the fold: implementation so I'm bummed
it's slightly slower ;) Personally I like fold: as a name (it's shorter and
more cuddly) and since we don't have map: (we have collect:) I don't find
the need to use reduce: compelling. But that's my preference. I won't
object if you replace fold: with reduce:/ I do note that Gilad used fold:
in Newspeak.
What do you prefer?
What do others prefer?
I know, choices, choices :)
best
Eliot
>
>
> Cheers,
> Levente
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20101102/3b38a95a/attachment.htm
More information about the Squeak-dev
mailing list
|