ToC DocOverview CGDoc RelNotes Index PermutedIndex
Allegro CL
Home Previous Up Next Table of Contents Index
  ANSI Common Lisp   18 Hash Tables   18.2 Dictionary of Hash Tables

18.2.14 sxhash Function

Syntax:
sxhash object    hash-code

Arguments and Values:
object - an object.

hash-code - a non-negative fixnum.

Description:
sxhash returns a hash code for object.

The manner in which the hash code is computed is implementation-dependent, but subject to certain constraints:

Examples:
 (= (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

Affected By:
The implementation.

Notes:
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.

Allegro CL Implementation Details:
None.


Home Previous Up Next Table of Contents Index
© Franz Inc. All Rights Reserved - File last updated 2022-07-25