[squeak-dev] IdentitySet>>collect:

David T. Lewis lewis at mail.msen.com
Sat Nov 29 20:27:52 UTC 2014

On Sat, Nov 29, 2014 at 03:55:57PM +0100, Levente Uzonyi wrote:
> On Fri, 28 Nov 2014, tim Rowledge wrote:
> >
> >On 28-11-2014, at 6:05 PM, Levente Uzonyi <leves at elte.hu> wrote:
> >
> >>I think the conclusion was that it's better to leave the method as it is, 
> >>because there's no better way to do it.
> >
> >There?s *always* a better way to do it. Somebody just has to think about 
> >it the right way.
> There are too many factors for a better solution to exist.
> Let's say we change the method to return a Bag. Some will say it's better 
> that way, because the resulting collection has the same size as the 
> original.
> And some people will say that you broke their code, because the following 
> will return false instead of true:
> | s t |
> s := #(1 2 3) asSet.
> t := s collect: [ :each | each ].
> s = t
> IMHO the best solution is still to replace sends of #collect: with
> #collect:as:, but it's a lot of work.

I like your argument for making it explicit. How about if we make it
explicit like this:

  anIdentitySet collect: [:e | ... ] as: Set

This would avoid the surprising behavior of having #collect: answer
a collection of size different from that of the original collection.


More information about the Squeak-dev mailing list