[squeak-dev] #collect: on strings

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
24 messages Options
12
Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: #collect: on strings

Nicolas Cellier-3
Damien Cassou <damien.cassou <at> gmail.com> writes:

>
> On Thu, Jun 26, 2008 at 9:23 AM, Bert Freudenberg <bert <at> freudenbergs.de>
wrote:
> > 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:.
>
> +1
>

Whatever attracting the idea might be,
implementation won't be obvious, some recipient collections using add:, some
others at:put:.

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...
#collect:fromArrayedCollection:.

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.

Nicolas


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: #collect: on strings

Stéphane Rollandin
Nicolas Cellier a écrit :
> The idea of simplifying code by factorization might be spoiled by these details,
> and IMO is void.

+1 again

I don't see any problem with what we currently have.

Stef


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: #collect: on strings

Bert Freudenberg

Am 26.06.2008 um 13:11 schrieb Stéphane Rollandin:

> Nicolas Cellier a écrit :
>> The idea of simplifying code by factorization might be spoiled by  
>> these details,
>> and IMO is void.
>
> +1 again
>
> I don't see any problem with what we currently have.


Same here. And if someone is worried about the performance hit of  
#asArray, they probably shouldn't be using #collect: in the first place.

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: #collect: on strings

stephane ducasse
In reply to this post by Nicolas Cellier-3
I still think that I would like to see the result of an efficient  
as:collect:.
Damien I would like to find the time to write ToCo (trait for  
collection :)).
I understand the motivation of damien.
The discussion was interesting for me. I like when nothing is black  
and white because
this is that we closer to real life.

Stef

> Whatever attracting the idea might be,
> implementation won't be obvious, some recipient collections using  
> add:, some
> others at:put:.
>
> 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...
> #collect:fromArrayedCollection:.
>
> 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.
>
> Nicolas
>
>
>


12