Philosophical questions about collections

Bob Arning arning at charm.net
Fri Jun 29 13:34:14 UTC 2001


Diego,

On Fri, 29 Jun 2001 09:51:00 -0300 Diego Gomez Deck <DiegoGomezDeck at ConsultAr.com> wrote:
>I can't find the correct way to think about #= message for collections...

You are not alone in this feeling. ;-)

>For example, Dictionary use Set>>= that ignores keys.
>
>Bag, has not implemented the message.
>
>All the SequenceableCollection family seems to be good (IMHO).
>
>There exists a message that compares the elements of a collection with 
>another ignoring the collection species?

I don't think so, but you could do something like

	collection1 asSet = collection2 asSet
or
	collection1 asArray = collection2 asArray

The fact that these two options could easily produce different results suggests that there may be more than one way to think about collection equality. My inclination would be to write a method that did what I wanted in a particular situation and try to make it clear whether the order of the elements was important or not and whether duplicate elements should affect the result. Other factors, such as the precise way of comparing elements, may also be important.

Cheers,
Bob





More information about the Squeak-dev mailing list