Composite keys in Dictionary

Lee Salzman lsalzman1 at cox.net
Sun Sep 26 19:00:01 PDT 2004


This is from a bug in hashing Sequences that was fixed in CVS but is
still present in the 0.3 release.

If you don't feel like going through the trouble of upgrading from CVS,
you can just add the following method to your private image:

c@(Sequence traits) hash
[| hash |
  hash: c traits identityHash.
  c doWithIndex: [| :each :index | hash: (hash + each hash) hashMultiply].
  hash
].

On Sun, Sep 26, 2004 at 07:44:04PM +1000, Daniel John Crowe wrote:
> 
> 
> Hi,
> 
> I'm just introducing myself to the slate world (0.3) and I've come up against an issue.
> 
> I've been trying to add composite keys to a dictionary.
> ie:    dict at: (keya , keyb) put: val.
> 
> The dictionary uses an identity hash on the tuple, and this prevents me from using a new tuple to read the value from the dictionary.
> 
> ie:   dict at: (keya, keyb). "fails"
> 
> What is the best way around this?
> 
> Thanks, Daniel Crowe.
> 
> 
> 




More information about the Slate mailing list