Support of algebraic operations on sets

Klaus D. Witzel klaus.witzel at cobss.com
Fri Jun 15 16:54:34 UTC 2007


On Fri, 15 Jun 2007 18:39:21 +0200, sig wrote:
> On 15/06/07, Klaus D. Witzel <klaus.witzel at cobss.com> wrote:
>> On Fri, 15 Jun 2007 18:04:19 +0200, sig wrote:
>> >>
>> >> So you do (aDict keys op: bDict keys)? Is any #op: you need for that  
>> not
>> >> in Set and its superclasses?
>> >>
>> > No its not. But i'd rather like to see aDict op: bDict with same
>> > semantics.
>>
>> An example:
>>
>> aDict := Dictionary with: $a->1 with: $c->2.
>> bDict := Dictionary with: $b->3 with: $c->4.
>>
>> aDict union: bDict
>>
>> => a Dictionary($a->1 $b->3 $c->4 )
>>
>> Why would anybody be happy with $c->4, I expected $c->2. You see what I
>> mean (when I wrote earlier that no cDict can hold the "correct" values)?
>>
>> The expected result is application specific, no?
>>
> i would care of seeing correct number of keys in algebraic ops at first  
> place.

Ah :)

aColl := OrderedCollection with: $a->1 with: $c->2.
bColl := OrderedCollection with: $b->3 with: $c->4.
aColl union: bColl
a Set($a->1 $c->2 $b->3 $c->4)

You also might want to consider using

Association subclass: #SigAssociation ...
SigAssociation methodsFor: 'comparision'
= argv
	^ super = argv and: [self value = argv value]

/Klaus




More information about the Squeak-dev mailing list