Equality of Recursive Structures [Was: Closure Compiler in 3.9 ?]

sig siguctua at gmail.com
Sat May 12 07:31:32 UTC 2007


On 11/05/07, nicolas cellier <ncellier at ifrance.com> wrote:
> Lukas Renggli a écrit :
> >> Cue another long discussion about hashing.
> >>
> >> Just what do you believe the hash value should be based on?
> >
> > What about the key only?
> >
> > I quickly had a look at some other Smalltalk implementations (VW,
> > Dolphin, Ambrai) they all use the key for hashing only.
> >
> > Lukas
> >
>
> As a LookupKey, Association should behave like Lukas said.
> Also, look at this funny bug introduced by Association>>#= :
>
> | a1 a2 |
> a1 := #a -> 1.
> a2 := #a -> 2.
> {a1 >= a2. a2 >= a1. a1 = a2}
>         "true, true, false"
>
> I do not know how mathematicians do qualify this kind of relation...
>
>
> But among more than 30 references to Association, and 100 sendes of #->
> how to tell whether Association>>#= ever need to test the value ?
> (this is of course why Associations>>#hash is defined )
>
> Quiet sure there are some uses that do not consider Association like a
> LookupKey but just as a C++ std::pair.
>
> Nicolas
>
Why then not add class Pair, and then Association as subclass.
We can leave a selector #->, to create Association and use #=> (or
other) to create Pair
The Pair #= will compare both left and right values , while
Assotiation only on first.
Same with #hash.



More information about the Squeak-dev mailing list