[BUG] Set>>collect:

Bill Spight bspight at pacbell.net
Fri Feb 14 03:01:54 UTC 2003

Dear Richard,

> The essential point about #collect: is that the transformation block
> does NOT in general return objects of the same type that it is passed.

Well, in Squeak it seems to, in general. There are a few exceptions.

> Just because identity is the right individuation criterion for items
> x y in a set, that does not mean that it is the right individuation
> criterion for (someBlock value: x) and (someBlock value: y).

Point well taken.

You make an excellent case for collect:into: . That gives flexibility
for those cases where you want to apply a different criterion to the new

As for the case of the code in Set, Set in Squeak has 4 children:
Dictionary, Identity Set, Pluggable Set, and Weak Set. Dictionary and
Weak Set override collect: So the question comes down to Pluggable Set
vs. Identity Set. If it is desirable to have PluggableSet>>collect:
create a Set rather than a Pluggable Set, can't you take care of it in
PluggableSet, and leave the general behavior the same in both Set and

Isn't this also to some extent a question of documentation? The general
rule is set out in the comment in Collection. It would be reasonable to
add to that comment that 3 collections are exceptions: Dictionary,
SortedCollection, and PluggableSet. The natural place to look for the
code covering those exceptions is in those classes, right?

Best regards,


More information about the Squeak-dev mailing list