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

EQUAL isn't really correct, I agree

Several months ago I came to the same conclusion, that none of the equality
predicates are correct for many structure-comparing operations, and I roughly
sketched out what would be better: a flexible structure-comparing function.
Basically you tell the function what kinds of primitive cells should be
STOP points and what should be recurse-through cells (the union of the
two sets should be the universe of data types, or at least should include
every kind of cell encountered in the task at hand). At STOP points, some
more primitive function is needed to perform the actual comparison, so you
tell the general function what primitive comparison function is to be used
at each STOP point. Also, at each recurse-through some method of mapping
all the components is needed, which would be implicit in the function
definition for built-in datatypes but may need to be described explicitly
for user-defined datatypes or for deliberately not recursing down certain

Typical variations on the usual EQUAL that would be supported trivially
by this method:  Identifiers get compared by PNAME rather than EQ, thus
matching non-interned identifiers correctly.  Numbers get compared with
fudge factor that is magnitude-dependent in unusual way.  Recursion occurs
through the VALUE and PROPERTY-LIST of each identifier that is in the
FOO package but stops on other identifiers (hint, make identifiers STOP
points but define the comparison function at that point to look at the
package cell and explicitly call the super-equal function recursively
in some cases).  ...

Once this super-general function is properly defined and implemented,
special cases can be described in a uniform way as canned arguments to
this function, and then can be handcoded more efficiently if desired.

In many cases there are oodles of special-case functions and nothing
properly general in CL currently. Perhaps general functions should be
defined and some of the special cases flushed, as such cases are recognized?
Super-general-EQUAL could be the first such super-general function?