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

(eq #'f #'f) and :TEMPORARY hash tables



re: ... if equivalence of closures is something different from EQ, I have 
    trouble figuring out what it would be defined as that would have any 
    meaning that was both portable and effectively computable.

There is a rather simple equivalence used internally in Lucid Common
Lisp -- not unlike extending EQUAL to pointer vectors -- by recursive 
descent into the "components" (of course, just what the "components" of 
a function/closure are is an implementation dependent issue).  It is
used during a "coalescing" phase, when functions can be made read-only.

However, in terms of the (eq #'f #'f) issue, the way in which EQL could
reasonably differ from EQ is the same way in which it does so in
Interlisp-D -- namely, evaluating (FUNCTION F) is not merely a field
access into a symbol structure, but rather the consing up of a trivially 
small structure that holds normal pointers for the components of the "real"
function named by F.  Because of the lower-level internals, it wasn't
convenient for Interlisp-D to retain, for example, the address of the
function's code as a first-class pointer; so evaluating #'F would
simply normalize the internal bits, and return them in a freshly-cons'd
up structure.  For "functions" x and y, (EQP x y) is more or less like
	(and (eq (component-1 x) (component-1 x))
	     (eq (component-2 x) (component-2 x))
	     ...)
[but not every conceivable component is included in this compound test.]


-- JonL --


P.S. I'm not really serious about extending EQL to act like Interlisp's
     EQP on functions.  The original motivation for this discussion was
     the characterization of hash-table equivalence predicates; and
     certainly, means other than the temporal value of #'f can be used
     to identify the test.  To my knowledge, only Symbolics and Lucid have
     any hooks for permitting random :test functions to be used in hash
     tables (Lucid's facilities are not "exported" to the end customer),
     and neither of these implementations has the EQ/EQP difficulty on
     global functions.