[squeak-dev] true hash

Chris Muller asqueaker at gmail.com
Wed May 9 20:19:45 UTC 2012


>> Where do true, false and nil obtain their hash value?  They inherit
>> #hash from Object, so it is their identityHash, but I noticed this is
>> consistent between images -- how?  It's great, but is there any danger
>> of that value ever changing?  That would be bad..
>
>
> The identity hash bits are stored in each object's header. And since true, false, nil are the same decades old instances, their hash did not change.
>
> Depending on what the SystemTracer does, it may be different in an image derived by that though. E.g. you may want to check a 64 bit image.

So, just in thinking about it -- that is a VERY distant dependency
that could manifest as a bug way up in at an app-level in production.
Because no SUnit test would be able to catch it, and when trying to
debug it in production, invariably someone with the "classic" hashes
not be able to reproduce the problem..  Hopefully it would only be a
"lookup" problem but what if it was in the context of an
#at:ifAbsentPut:?  What a nightmare!

So, it would seem a good idea to override #hash to return their
current value as a fixed constant.

Thoughts?


More information about the Squeak-dev mailing list