From: Ihor Radchenko <yantar92@gmail.com>
To: rms@gnu.org
Cc: schwab@suse.de, emacs-devel@gnu.org
Subject: Re: Comparing hash table objects
Date: Sat, 11 Jun 2022 13:52:25 +0800 [thread overview]
Message-ID: <878rq3d9wm.fsf@localhost> (raw)
In-Reply-To: <E1nznNY-0008R6-Tb@fencepost.gnu.org>
Richard Stallman <rms@gnu.org> writes:
> It clearly can be useful to compare hash tables for equivalence
> of contents. I see two ways to offer that facility:
>
> * As a new function. That would be upward-compatible.
I have seen various variants of such function in third-party packages
and just in internet search results.
For example, ht-equal? from
https://github.com/Wilfred/ht.el/blob/master/ht.el:
(defun ht-equal? (table1 table2)
"Return t if TABLE1 and TABLE2 have the same keys and values.
Does not compare equality predicates."
(declare (side-effect-free t))
(let ((keys1 (ht-keys table1))
(keys2 (ht-keys table2))
(sentinel (make-symbol "ht-sentinel")))
(and (equal (length keys1) (length keys2))
(--all?
(equal (ht-get table1 it)
(ht-get table2 it sentinel))
keys1))))
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).
> * By making `equal' compare them that way. That would fit the spirit
> of `equal', but could break some existing uses of `equal'.
I'd say that using `equal' on hash tables with the actual intention of
comparing tables by `eq' is calling for a trouble. At least, it is
misleading.
Best,
Ihor
next prev parent reply other threads:[~2022-06-11 5:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <87wn1axgh6.fsf@breatheoutbreathe.in>
[not found] ` <83jzx925lv.fsf@gnu.org>
[not found] ` <87a5xubwoo.fsf@breatheoutbreathe.in>
[not found] ` <87v8csku60.fsf@breatheoutbreathe.in>
[not found] ` <83cyyz94c6.fsf@gnu.org>
[not found] ` <87a5u2ydzg.fsf@breatheoutbreathe.in>
[not found] ` <83msy25g0s.fsf@gnu.org>
[not found] ` <624CBB7F-1442-400D-8D4D-1B26EBE9DACB@breatheoutbreathe.in>
[not found] ` <jwvr0ndq3b8.fsf-monnier+emacs@gnu.org>
[not found] ` <877cp5bmig.fsf@breatheoutbreathe.in>
[not found] ` <jwvtts8ib4b.fsf-monnier+emacs@gnu.org>
2022-06-08 8:41 ` Comparing hash table objects Ihor Radchenko
2022-06-08 8:51 ` Andreas Schwab
2022-06-08 9:17 ` Ihor Radchenko
2022-06-10 22:45 ` Richard Stallman
2022-06-11 5:52 ` Ihor Radchenko [this message]
2022-06-11 16:04 ` Stefan Monnier
2022-06-12 9:16 ` Ihor Radchenko
2022-06-12 23:55 ` Sam Steingold
2022-06-13 13:02 ` Stefan Monnier
2022-06-13 16:18 ` Sam Steingold
[not found] ` <8734zoaolv.fsf@localhost>
[not found] ` <jwv1qf8iqua.fsf-monnier+emacs@gnu.org>
[not found] ` <87fs3o8uil.fsf@localhost>
[not found] ` <87msxwa8kd.fsf@breatheoutbreathe.in>
[not found] ` <87il8j7ji9.fsf@localhost>
[not found] ` <80479897-500e-fe60-6586-0a44ccb5993b@daniel-mendler.de>
[not found] ` <877coz7f6h.fsf@localhost>
[not found] ` <86d6e412-9e5b-9086-56ce-e3794085096a@daniel-mendler.de>
2023-09-09 12:12 ` compat.el and Emacs unstable master branch features (was: bug#63513: [PATCH] Make persist-defvar work with records and hash tables) Ihor Radchenko
2023-09-09 12:29 ` Daniel Mendler
2023-09-09 16:52 ` Joseph Turner
2023-09-11 8:45 ` Ihor Radchenko
2023-09-12 10:02 ` compat.el and Emacs unstable master branch features Philip Kaludercic
2023-09-12 10:27 ` Daniel Mendler
2023-09-13 10:31 ` Philip Kaludercic
2023-09-13 17:11 ` Daniel Mendler
2023-10-15 8:43 ` Ihor Radchenko
2023-10-15 12:09 ` Philip Kaludercic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878rq3d9wm.fsf@localhost \
--to=yantar92@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=rms@gnu.org \
--cc=schwab@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).