Support of algebraic operations on sets

sig siguctua at gmail.com
Fri Jun 15 16:58:00 UTC 2007


On 15/06/07, Ron Teitelbaum <Ron at usmedrec.com> wrote:
> Why can't we use both keys and values?
>
> aDict1 := Dictionary new
>         at: #A put: 1;
>         at: #B put: 1;
>         at: #C put: 2;
>         at: #D put: 2;
>         yourself.
>
> aDict2 := Dictionary new
>         at: #B put: 1;
>         at: #C put: 1;
>         at: #D put: 2;
>         at: #E put: 2;
>         yourself.
>
> aDict1 intersection: aDict2 =
>         #(#B->1 #D->2)
>
> aDict1 difference: aDict2 =
>         #(#A->1 #C->2)
>
> aDict2 difference: aDict1 =
>         #(#C->1 #E->2)
>
> aDict1 symetricDifference: aDict2 =
>         #(#A->1 #C->#(1 2) #E->2)
>
> aDict1 union: aDict2 =
>         #(#A->1 #B->1 #C->#(1 2) #D->2 #E->2)
>
> Wouldn't this make the most sense for dictionaries?  I know the values of
> the resulting dictionary need special handling but wouldn't a developer
> expect to have to handle this situation this way?
>
As you can see results in your examples have no value at all. There's
no parallels from algebra, to produce such results. And using such ops
on dictionaries with current semantics is meaningless.

Lets take an example from real life: we have two dictionaries with
translation of words from one language into another. Now, the task is
to compare these books to find out, what book contains more
translations and to find out what words is missing in first book that
holds second one. Then, after finding them out, merge new words with
first book. Or remove them from second book.

> Everything else seems to leave out valuable information.
>



More information about the Squeak-dev mailing list