There are two important properties of sxhash : if (equal xy) then (= (sxhash x) (sxhash y)) , and the value returned by sxhash is the same for any object (even between lisp images).
Now the structures are equal , if only they have eq (i.e. they have the same address), but sxhash cannot just return the address (or some hash) of the structure, because the address can change due to garbage collection. When designing an lisp implementation, you must choose whether to have sxhash the same for each structure or to store some credentials in each structure that does not change when the garbage collector moves the structure and therefore can be used for an sxhash object. Most implementations (including Franz and sbcl) believe that adding such a value is a waste of space or useless if it is provided with only a few spare bits.
This compromise will ultimately only affect the user's attempt to implement hash tables, as their own hash tables of implementations can use the address of the objects and tell the garbage collector so that they can rephrase when moving the object (I donโt know, or no implementations do this) . Some implementations (including sbcl) allow you to configure built-in hash tables using your own comparison / hash operations. Perhaps if you implemented hashing, you could add additional fields to them.
I believe that the result returned by sxhash in sbcl is determined by hashing the name of the structure type.
source share