Re: [PATCH] Implement `equal' for hash tables

Nix <[email protected]> Wed, 05 Aug 2026 12:38:34 +0100
Newsgroups gmane.emacs.devel
Message-ID <[email protected]>
On 5 Aug 2026, Sean Whitton verbalised:

> Nick Alcock [04/Aug  9:16pm +01] wrote:
>> Hash tables are equal if they have equal atoms, weakness, and equality
>> and hash functions.
>>
>> (This also means that equal of structures which contain hash tables is
>> useful now, too, which is really the reason I implemented this: right
>> now, hash tables are a sort of poison pill which render any object into
>> which they are inserted unequal with all others.  No more.)
>
> Is it useful in a programming language for hash table objects to be
> directly comparable like this?  I'm not sure that it is.

I'd say, just as much as alists or plists, to which they are
semantically similar -- but the real utility, as noted above, is if you
have data structures with hashtables embedded in them. Right now,
'equal' is instantly useless on such data structures, recursively, which
means I'm always writing my own halfwitted reimplementations in Lisp to
prevent spurious nil returns on data structures that actually have the
same content, some of which is embedded in hashtables because it's fifty
thousand items or so.

Having to do this seems to me like a huge waste of time compared to just
having 'equal' treat hashtables more or less like every other
key/value-pair data structure.

(For obarrays, I agree, because embedding obarrays in other structures
is extremely rare, and you never really use them in contexts in which
comparing them makes sense -- but a hashtable is a general data
structure. Of *course* you want to be able to see if two hashtables have
the same content! The effect of changes in weakness, hashing function
etc is more debatable, and in particular I'm definitely persuadable that
differences in the hashing and comparison functions in particular
shouldn't determine equality of two hashtables, since changing that
doesn't affect the content, and the content is what really matters.)

-- 
NULL && (void)