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

MAKE-HASH-TABLE :TEST arg



    Date: Mon, 12 Sep 88 15:45 EDT
    From: David A. Moon <Moon@stony-brook.scrc.symbolics.com>

	Date: Mon, 12 Sep 88 11:05 EDT
	From: Barry Margolin <barmar@Think.COM>

	I suppose you COULD use SXHASH for all hash tables, since EQ objects are
	necessarily EQUAL

    Not if the following program is valid Common Lisp.  I couldn't find anything
    in CLtL that speaks to this.  Should this be run through the cleanup committee?

      (setq ht (make-hash-table :test #'eq))
      (setq a (cons 1 2))
      (setf (gethash a ht) 'win)
      (setf (cdr a) 3)
      (gethash a ht 'lose) => win t

    If SXHASH was used, the last form would evaluate to lose nil unless
    by chance (= (sxhash '(1 . 2)) (sxhash '(1 . 3))) was true or by
    chance the structure of the hash table was such that the difference
    between the two sxhash values did not matter.  Similar
    examples can be constructed using strings and bit-vectors in place of
    conses.

    I would propose that modifications to components of the key do not
    affect EQ and EQL hash tables, and thus are allowed, but are not
    allowed for EQUAL hash tables when the modification is to a component
    that is examined by the EQUAL function.

You're right.

                                                barmar