sxhash
object => hash-code
object---an object.
hash-code---a non-negative fixnum.
sxhash returns a hash code for object.
The manner in which the hash code is computed is implementation-dependent, but subject to certain constraints:
(= (sxhash (list 'list "ab")) (sxhash (list 'list "ab"))) => true (= (sxhash "a") (sxhash (make-string 1 :initial-element #\a))) => true (let ((r (make-random-state))) (= (sxhash r) (sxhash (make-random-state r)))) => implementation-dependent
The implementation.
Many common hashing needs are satisfied by make-hash-table and the related functions on hash tables. sxhash is intended for use where the pre-defined abstractions are insufficient. Its main intent is to allow the user a convenient means of implementing more complicated hashing paradigms than are provided through hash tables.
The hash codes returned by sxhash are not necessarily related to any hashing strategy used by any other function in Common Lisp.
For objects of types that equal compares with eq, item 3 requires that the hash-code be based on some immutable quality of the identity of the object. Another legitimate implementation technique would be to have sxhash assign (and cache) a random hash code for these objects, since there is no requirement that similar but non-eq objects have the same hash code.
Although similarity is defined for symbols in terms of both the symbol's name and the packages in which the symbol is accessible, item 3 disallows using package information to compute the hash code, since changes to the package status of a symbol are not visible to equal.
Go to the first, previous, next, last section, table of contents.