emacs-devel
[Top][All Lists]
Advanced

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

Re: Comparing hash table objects


From: Sam Steingold
Subject: Re: Comparing hash table objects
Date: Sun, 12 Jun 2022 19:55:08 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

> * Stefan Monnier <zbaavre@veb.hzbagerny.pn> [2022-06-11 12:04:46 -0400]:
>
>> However, it will not help with the problem of comparing objects
>> containing hash tables. Unless those obejcts also define special
>> comparison function (which is inconvenient).
>
> This is an instance of a fairly general problem with Lisp's equality
> tests (and it's not really specific to Lisp, admittedly).

Sadly, this is true.

> Maybe a half-sane way to solve this problem is to provide a generic
> "equality driver" which takes an argument specifying which objects to
> compare for structural equality (i.e. where to keep recursing).

The way Python does it could be a good starting point:
unless a class defines __eq__ method, the comparison is Lisp eq.
So, if a class has structure, it should define the comparison method.
See https://docs.python.org/3/reference/datamodel.html#object.__eq__

-- 
Sam Steingold (http://sds.podval.org/) on Pop 22.04 (jammy) X 11.0.12101003
http://childpsy.net http://calmchildstories.com http://steingoldpsychology.com
https://ij.org/ http://think-israel.org https://fairforall.org
(let ((a "(let ((a %c%s%c)) (format a 34 a 34))")) (format a 34 a 34))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]