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

Re: Implementing :TEMPORARY hash tables at the Lisp level?

> Just a question.  If one were to implement :TEMPORARY hash tables as
> described - i.e. testing to see if the test were #'EQ or #'EQL - well,
> just how does one code such a test in CL?  Presumably you'd have code like
>  (case test 
>        ((#'eq #'eql) (make-em-collectible))
>        ((#'equal)    (dont-make-em-collectible))
>        (otherwise    (make-em-whatever-you-want)))
> But... there is no way of testing equality of functions, lexical closures,
> or what have you, in CL.  So how can this possibly be implemented?

This problem already exists for hash tables: something must see whether
the :TEST argument is EQ, EQL, or EQUAL.  I suspect this involves code
like the following:

   (cond ((or (eq test #'eq) (eq test 'eq))
          ...eq hash table...)
         ((or (eq test #'eql) (eq test 'eql))
          ...eql hash table...)
         ((eq (eq test #'equal) (eq test 'equal))
          ...equal hash table...)
         (t ...whatever...))

Functions can be compared with EQ, EQL, and EQUAL, but the meaning is
not "do they compute the same (mathematical) function".  Code like
the following will not work:

   (make-hash-table :test #'(lambda (a b) (eq a b)))

-- Jeff