Support of algebraic operations on sets

sig siguctua at gmail.com
Fri Jun 15 16:27:57 UTC 2007


On 15/06/07, Bert Freudenberg <bert at freudenbergs.de> wrote:
> On Jun 15, 2007, at 17:34 , sig wrote:
>
> >> The actual problem here is that Dictionary is implemented as a
> >> subclass of Set while it is no proper Set. If it wasn't, then the
> >> #union: implementation in Collection would do The Right Thing. Of
> >> course we'd need Dictionary>>asSet defined as "^self values asSet".
> >>
> > no, it leads nowhere , because if you return keys or values in #asSet
> > you losing opposite part of assotiation. also note, that 'self value
> > asSet' will return you a set where same value appear only once, which
> > is not true for dictionary.
>
> Err, we *are* talking about #asSet, which indeed should return a Set
> without duplicates.
>
> > I'm not agree. A values in dictionary are accessible only by keys.
>
> Huh? #do: does not need any keys.
>
> > They have no meaning w/o keys.
> > Keys in dictionary much more sensible than values. And that's why
> > dictionaries inherited from sets IMHO. And must behave as sets in
> > union/difference/intersection operations based only on keys.
>
> I guess these are two different views of Dictionaries. I see them as
> unordered variable-sized collections with non-integer indices. Except
> for order, a Dictionary with integer keys should pretty much behave
> like an OrderedCollection.

The main difference between OrderedCollection and Dictionary lies in
insertion/deletion operations, while OrderedCollection serves to
preserve the order of elements (based on < or > operator)
Dictionaries, in contrast, serve to preserve unique placeholder for
values under same key (based on = operator).
OrderedCollection maintains own index (by placing elements in right
order and accessing them in array-like fashion), while Dictionary
gives user a way to maintain own, custom defined index.

I can't use an Association for insertion/deletion operations because
it violates the rules of dictionary (take into account only key, not
value when comparing with = operator). And this is ridicules.

>
> You seem to think of Dictionaries as a collection of Associations,
> with meaning sometimes placed on the keys, the values, or both. I
> guess that's where our difference in understanding comes from.
>
> - Bert -
>



More information about the Squeak-dev mailing list