symbol-hash(3scm) Scheme Programmer's Manual symbol-hash(3scm)

symbol-hash - symbol hash function

(import (rnrs))                     ;R6RS
(import (rnrs hashtables))          ;R6RS

(symbol-hash symbol)

Returns an integer hash value for symbol.

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.

Returns a single value; an (exact) integer.

(let ((ht (make-hashtable symbol-hash eq?)))
  (hashtable-set! ht 'car 'vehicle)
  (hashtable-set! ht 'blue 'color)
  (hashtable-ref ht 'car #f))
        =>  vehicle

This procedure is used with make-hashtable(3scm) together with eq?(3scm).

This procedure is unique to R6RS. Similar procedures exist in SRFI-126 and SRFI-128.

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.

equal-hash(3scm), make-hashtable(3scm)

R6RS

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.

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