[BUG] Set>>collect:

Bill Spight bspight at pacbell.net
Mon Feb 17 01:24:32 UTC 2003

Dear Richard,

>         By contrast, if sending collect: to IdentitySet produces a Set, it is
>         too late to go back and put in those elements that were rejected because
>         they were equal, but not identical. It is OK to go from IdentitySet to
>         Set, but not the other way.
> So what?  All that means is "if you have a collection and you want an
> IdentitySet result, DON'T USE #collect: TO DO IT."  It's precisely the
> problem that #collect:into: is designed to solve.

#collect:into: is very nice. :-) Its flexibility reduces the problems
with #collect:

> There is only a problem when you have a set of results which support
> both identity and a *distinct* notion of equality AND you happen to
> know that this time you want identity.
> If you consider transformation blocks that return Numbers or Strings
> (something mine quite often do), you'll see why I assume that equality
> is a far better default than identity.

I agree that you usually want equality, not identity. But when you do,
and therefore use IdentitySet, that changes things. *In such cases*, the
default should be identity.



P. S. I think we have both expressed our cases pretty fully.
#collect:into: significantly reduces the problems. If you want to have
the last word, be my guest. :-)

More information about the Squeak-dev mailing list