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

Implementing :TEMPORARY hash tables at the Lisp level?



    Date: Wed, 7 Sep 88 07:52 EDT
    From: "Steve Bacher (Batchman)" <SEB1525@draper.com>

    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?

The internal implementation of a Common Lisp need not be written using
portable constructs.

I suspect that in most CL implementations, #'<symbol> always returns the
same thing for symbols that do not have a lexical function binding, so
the above code would work.  If not, then the hash table implementation
will have to use some implementation-dependent functions to extract the
function object from a closure and compare it against the function
bindings of EQ, EQL, and EQUAL.

In fact, current implementations of MAKE-HASH-TABLE must already have
something like this, since the hash function of a hash table must be
dependent on the :TEST argument.

                                                barmar