[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EQUALP hash tables (and more ...)



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