Marten Feldtmann
unread,Jul 31, 2011, 4:56:35 AM7/31/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to va-sma...@googlegroups.com
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 ....