[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: EQUALP hash tables (and more ...)
- To: Wholey@CMU-CS-C.ARPA, Fahlman@CMU-CS-C.ARPA, Common-Lisp@SU-AI
- Subject: Re: EQUALP hash tables (and more ...)
- From: Dan Hoey <hoey@nrl-aic.ARPA>
- Date: Sun, 12 May 1985 23:12:00 -0000
- In-reply-to: Msg of 11 May 1985 15:29 EDT from Skef Wholey and Msg of 11 May 1985 10:59-EDT from Scott E. Fahlman
Skef,
I was about to bring up the problem you mentioned:
``I don't think it's possible to let users write some form of hashing
function that generates = numbers for EQ objects.''
but then I noticed that the language already provides a mechanism for
writing a perfect EQ hashing function:
(DEFVAR *EQ-HASH-TABLE* (MAKE-HASH-TABLE :TEST #'EQ))
(DEFVAR *EQ-HASH-COUNTER* 0)
(DEFUN EQHASH (X)
(OR (GETHASH X *EQ-HASH-TABLE*)
(SETF (GETHASH X *EQ-HASH-TABLE*) (INCF *EQ-HASH-COUNTER*))))
It is a pity that there's no way to let the GC collect stuff out of the
*EQ-HASH-TABLE* for fear of breaking MAPHASH. Maybe there should be
some way of declaring a hash table GC-able, perhaps by declaring it
un-MAPHASH-able.
Dan