[squeak-dev] Re: #collect: on strings
ncellier at ifrance.com
Thu Jun 26 10:44:41 UTC 2008
Damien Cassou <damien.cassou <at> gmail.com> writes:
> On Thu, Jun 26, 2008 at 9:23 AM, Bert Freudenberg <bert <at> freudenbergs.de>
> > Am 26.06.2008 um 08:11 schrieb Klaus D. Witzel:
> >> And by code duplication, #collect:into: could do the job ;)
> > If you indeed need this, I'd propose as:collect:.
Whatever attracting the idea might be,
implementation won't be obvious, some recipient collections using add:, some
Probably you will have to dispatch to recipient sending a #collect:from:.
Then if you want to preserve efficiency of optimized to:do: loops in case both
collections are ArrayedCollection, or at least recipient is Arrayed and source
is Sequenceable, then you might have to implement double dispatching...
Double dispatching would be a must to handle tricky Dictionary case - use same
keys when collecting into a Dictionary, arbitrary key remapping when collecting
into an ArrayedCollection and no key at all when collecting into a Bag or Set...
The idea of simplifying code by factorization might be spoiled by these details,
and IMO is void.
More information about the Squeak-dev