Larry Valkama <remlali@...> writes:
> Is this correct ?
> * (loop for i from 0 below 10 do
> (print (sxhash (sb-thread:make-thread (lambda ())))))
Don't know about correct, but at least it's working as intended :-)
SXHASH must always return the same value for the same input, unless
the object is visibly modified as tested by EQUAL. In a system with a
copying GC this means that we can't use the address of an instance as
the return value of SXHASH on a structure. Nor is there any extra
space in the structure memory layout for storing some kind of a stable
identifier for each instance. Thus the only [*] solution would be to
add an extra sot to all instances and arrays, which I suspect would be
unacceptably large memory bloat.
Note that SBCL does not internally use SXHASH for EQUAL hash tables,
except for types where EQUALity is different from EQLity. So the bad
distribution of SXHASH values will only matter if you're trying to
implement your own hash tables.
[*] Barring heroic efforts like done by the JVMs, which will basically
dynamically mutate the object layout of an instance when the hashcode
is first accessed. It seems unlikely anyone will go through the trouble
of implementing this for SBCL.