Consider the following code:
| anIdentitySet anObject anObject2 |
anIdentitySet := IdentitySet new.
anObject := Point new x: 2.
anObject2 := Point new x: 2.
Transcript cr ; show: 'Hash-Value of first object: ', anObject basicHash asString.
Transcript cr ; show: 'Hash-Value of second object: ', anObject2 basicHash asString.
anObject y: 2.
Transcript cr ; show: 'Hash-Value of first object after change', anObject basicHash asString.
anObject := Point new x: 2.
anObject2 := Point new x: 2.
Transcript cr ; show: 'Hash32-Value of first object: ', anObject abtHash32 asString.
Transcript cr ; show: 'Hash32-Value of second object ', anObject2 abtHash32 asString.
anObject y: 2.
Transcript cr ; show: 'Hash32-Value of first object after change ', anObject abtHash32 asString.
the output is:
Hash-Value of first object: 31153
Hash-Value of second object: 31158
Hash-Value of first object after change31153
Hash32-Value of first object: 841485990
Hash32-Value of second object 841485990
Hash32-Value of first object after change 264182029
Several remarks about this:
1) The method comment for basicHash is wrong and should be changed to " ... Objects that are identical (==) must ....."
"Answer a SmallInteger that represents the receiver. Objects that are equivalent (=) must
answer the same value for the message #basicHash."
2) In the past several users had problems with the 16-bit limitatons of basicHash and the idea was to use abtHash32 as a replacement for basicHash. But as you can see from the output and the code above: this is not useable. The value changes even when you change a simple attribute.
Therefore the question: You can we get IdentitySet, but with 32-bit wide keys ....
--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/va-smalltalk/-/UjB-yOuHIhkJ.
To post to this group, send email to
[hidden email].
To unsubscribe from this group, send email to
[hidden email].
For more options, visit this group at http://groups.google.com/group/va-smalltalk?hl=en.