| symbol-hash(3scm) | Scheme Programmer's Manual | symbol-hash(3scm) |
NAME
symbol-hash - symbol hash function
LIBRARY
(import (rnrs)) ;R6RS (import (rnrs hashtables)) ;R6RS
SYNOPSIS
(symbol-hash symbol)
DESCRIPTION
Returns an integer hash value for symbol.
IMPLEMENTATION NOTES
Symbol names are immutable and therefore the hash value can be computed once and stored in the object. It is possible to delay the computation until the hash is needed, similarly to how Chez Scheme lazily generates the names of gensyms.
RETURN VALUES
Returns a single value; an (exact) integer.
EXAMPLES
(let ((ht (make-hashtable symbol-hash eq?)))
(hashtable-set! ht 'car 'vehicle)
(hashtable-set! ht 'blue 'color)
(hashtable-ref ht 'car #f))
=> vehicle
APPLICATION USAGE
This procedure is used with make-hashtable(3scm) together with eq?(3scm).
COMPATIBILITY
This procedure is unique to R6RS. Similar procedures exist in SRFI-126 and SRFI-128.
ERRORS
This procedure can raise exceptions with the following condition types:
- &assertion (R6RS)
- The wrong number of arguments was passed or an argument was outside its domain.
SEE ALSO
equal-hash(3scm), make-hashtable(3scm)
STANDARDS
R6RS
HISTORY
This procedure first appeared in R6RS. A similar procedure existed in the sample implementation of SRFI-69 but the official interface of that SRFI does not export it. Instead the generic hash procedure would be used for symbols.
AUTHORS
This page is part of the scheme-manpages project. It includes materials from the RnRS documents. More information can be found at https://weinholt.se/scheme/manpages/.
| 2023-03-20 |