GNU bug report logs - #63671
Add function to test equality of hash tables

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Joseph Turner <joseph@HIDDEN>; dated Tue, 23 May 2023 19:41:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 63671 <at> debbugs.gnu.org:


Received: (at 63671) by debbugs.gnu.org; 24 May 2023 17:29:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed May 24 13:29:09 2023
Received: from localhost ([127.0.0.1]:45026 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q1sIP-0000QC-5q
	for submit <at> debbugs.gnu.org; Wed, 24 May 2023 13:29:09 -0400
Received: from out-25.mta1.migadu.com ([95.215.58.25]:56638)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joseph@HIDDEN>) id 1q1sIM-0000Q3-JS
 for 63671 <at> debbugs.gnu.org; Wed, 24 May 2023 13:29:08 -0400
References: <D3833216-446C-4837-A7A4-3BD5AA9AC58A@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; 
 s=key1; t=1684949344;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=hgS164ejr2tJQI1psLNCzB1jwhU0omWH51lITDpK3rQ=;
 b=jv9HoHWEF+IvL+YHuGn4ygFiXTyR6NGYF0UFL1AyH40UuQfJGvhET+kC9EgXFLZ7fQT4jq
 0Wwm6LHh2dWdDTvrCIzFAaL2Z2JRZWhZj64P8owUJG6nvx+UdKoO3Coshszgonb50Cmc3/
 se2ZmxP8S//j3e14zDNXZCZufQZfqCg=
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Joseph Turner <joseph@HIDDEN>
To: Mattias =?utf-8?Q?Engdeg=C3=A5rd?= <mattias.engdegard@HIDDEN>
Subject: Re: bug#63671: Add function to test equality of hash tables
Date: Wed, 24 May 2023 10:27:13 -0700
In-reply-to: <D3833216-446C-4837-A7A4-3BD5AA9AC58A@HIDDEN>
Message-ID: <87y1ldk59f.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63671
Cc: 63671 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Mattias Engdeg=C3=A5rd <mattias.engdegard@HIDDEN> writes:

> Thank you, but this seems a bit too specific to your own requirements
> -- maybe you can keep that procedure locally where you need it?

It's no problem to keep the procedure local.

> The standard library must be generally useful with clear semantics.

Would extending `equal' to handle hash tables be generally useful?

Joseph






Information forwarded to bug-gnu-emacs@HIDDEN:
bug#63671; Package emacs. Full text available.

Message received at 63671 <at> debbugs.gnu.org:


Received: (at 63671) by debbugs.gnu.org; 24 May 2023 09:27:52 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed May 24 05:27:52 2023
Received: from localhost ([127.0.0.1]:41552 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q1kme-0003ft-90
	for submit <at> debbugs.gnu.org; Wed, 24 May 2023 05:27:52 -0400
Received: from mail-lf1-f47.google.com ([209.85.167.47]:60621)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <mattias.engdegard@HIDDEN>) id 1q1kmb-0003fT-J6
 for 63671 <at> debbugs.gnu.org; Wed, 24 May 2023 05:27:50 -0400
Received: by mail-lf1-f47.google.com with SMTP id
 2adb3069b0e04-4f3b5881734so662610e87.0
 for <63671 <at> debbugs.gnu.org>; Wed, 24 May 2023 02:27:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1684920463; x=1687512463;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:sender:from:to:cc:subject:date
 :message-id:reply-to;
 bh=I/hCct5/WJNRqV7dUR1+zNoXv6xReNuNd0J6PImw9Ks=;
 b=adpcGrEfqAhLtoUEs1REL0zVNsaG+3n8bxWTMK+aB6OYmXjAF6fxVs1h2JbHbHUwbZ
 sWgaxB8eye+uyQWOInBEVlDxTcrkL1Ymv4liRYb4mrtfhK1VQuel86+kARi57O7K0NAP
 w3yEcXhppICq1MC1qThsDv2a7Bte+1fdhcJP763wBLmxNNvchfwYfjAk2PQfEA3kcefv
 AWDx8TSTa9F52q6QbzJ/qOWb2mKi34kVXbNABZdp4/DpQ1EheuIfLAueQmpbuZ+wYDvQ
 oryYM1gNrZLo47x7pU1chiQn5DgGPq8mlzm33omPJeo2gkQaG23E5MkaOh8u4wqi5icP
 Wb7w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1684920463; x=1687512463;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:sender:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=I/hCct5/WJNRqV7dUR1+zNoXv6xReNuNd0J6PImw9Ks=;
 b=K5RatAA0aS2pLag4kU6dLgpTdUcR12zIHFs0cxloxgmp5ZJP1WwL0Wzx5xV2Zji8Kn
 v+m39FCPCxQwRrlyX+nXvcaQJ62e3p5irNj7F+scNz7WCOqgiKqUA+hxbG0AP5KQQDmZ
 wO6nzc+iz4vucp1Jb80jNWrdtSgTJvsijrBnISxdHde7blDyT712SX421E+7/nVKnQcW
 Rc8I6+08bfpbQkzJZzjPCzczFfVfj3iaEiiZGOb2hoia8APnryQR9pLahvY71xYSVw1V
 OoYyVYmCOywVXSWv9J3fZd5tQ43O6+Y3+6RsbikZVVexTv1M0gFI/UQmpo2TPrOppSGO
 c8EA==
X-Gm-Message-State: AC+VfDzCau9B95Skmp6IIantKA/ntVHDr2eL7KUpywjTRM4tuFOj6cJa
 l3/cbh2LWfEpzvP7V7BpsKzKHB10T9s=
X-Google-Smtp-Source: ACHHUZ7ZWZu1x60AYS9d3O1/GTXaT/Z89YcPDnAduAZPFF+GBUP4ZEaYrCbtQbkyPKQ8NMJdb3z4Tw==
X-Received: by 2002:ac2:4570:0:b0:4f4:ca64:3c9d with SMTP id
 k16-20020ac24570000000b004f4ca643c9dmr589973lfm.54.1684920463075; 
 Wed, 24 May 2023 02:27:43 -0700 (PDT)
Received: from smtpclient.apple (c188-150-165-235.bredband.tele2.se.
 [188.150.165.235]) by smtp.gmail.com with ESMTPSA id
 x4-20020ac24884000000b004f3b258feefsm1654327lfc.179.2023.05.24.02.27.42
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Wed, 24 May 2023 02:27:42 -0700 (PDT)
From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= <mattias.engdegard@HIDDEN>
Content-Type: text/plain;
	charset=us-ascii
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\))
Subject: bug#63671: Add function to test equality of hash tables
Message-Id: <D3833216-446C-4837-A7A4-3BD5AA9AC58A@HIDDEN>
Date: Wed, 24 May 2023 11:27:41 +0200
To: Joseph Turner <joseph@HIDDEN>
X-Mailer: Apple Mail (2.3654.120.0.1.15)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63671
Cc: 63671 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Thank you, but this seems a bit too specific to your own requirements -- =
maybe you can keep that procedure locally where you need it? The =
standard library must be generally useful with clear semantics.





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#63671; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 23 May 2023 19:40:14 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue May 23 15:40:14 2023
Received: from localhost ([127.0.0.1]:40446 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q1Xrh-0008PP-OB
	for submit <at> debbugs.gnu.org; Tue, 23 May 2023 15:40:14 -0400
Received: from lists.gnu.org ([209.51.188.17]:32940)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <joseph@HIDDEN>) id 1q1Xrf-0008PH-Kq
 for submit <at> debbugs.gnu.org; Tue, 23 May 2023 15:40:12 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <joseph@HIDDEN>)
 id 1q1Xrf-0001VV-6x
 for bug-gnu-emacs@HIDDEN; Tue, 23 May 2023 15:40:11 -0400
Received: from out-2.mta0.migadu.com ([2001:41d0:1004:224b::2])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <joseph@HIDDEN>)
 id 1q1Xrc-0002Lk-QV
 for bug-gnu-emacs@HIDDEN; Tue, 23 May 2023 15:40:10 -0400
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; 
 s=key1; t=1684870804;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type;
 bh=nwnoTo7gorEnCdom/hnGn60ldV0mgADYDUps5zqnw9g=;
 b=MLqa6sYNW0x2cURIWadEoGjGe8ZRZJVHoqQecO4CQsG12PHjTTCnbRlHikTWmtZGNrm220
 Z+yHiQZ+DC3LjhVaJdqme97cncgYVMKeZwW9EETRy5a7C7FnCvFZOKC3Gbydge3iRhY7SR
 vM+NhzmYNIBvyix6ghqUlXTs2FnOEBs=
From: Joseph Turner <joseph@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Add function to test equality of hash tables
Date: Tue, 23 May 2023 12:32:08 -0700
Message-ID: <87edn6bzvz.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
Received-SPF: pass client-ip=2001:41d0:1004:224b::2;
 envelope-from=joseph@HIDDEN; helo=out-2.mta0.migadu.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

Hello!

Would y'all be open to adding something like this?

(defun hash-equal (hash1 hash2)
  "Return non-nil when the contents of HASH1 and HASH2 are equal.
Table values are compared using `equal' unless they are both hash
tables themselves, in which case `hash-equal' is used.
Does not compare equality predicates."
  (and (= (hash-table-count hash1)
          (hash-table-count hash2))
       (catch 'flag (maphash (lambda (key hash1-value)
                               (let ((hash2-value (gethash key hash2)))
                                 (or (if (and (hash-table-p hash1-value)
                                              (hash-table-p hash2-value))
                                         (hash-equal hash1-value hash2-value)
                                       (equal hash1-value hash2-value))
                                     (throw 'flag nil))))
                             hash1)
              t)))

Rudimentary test:

(let ((hash1 (make-hash-table))
      (hash2 (make-hash-table))
      (hash3 (make-hash-table))
      (hash4 (make-hash-table)))
  (puthash 'foo "foo" hash1)
  (puthash 'foo "foo" hash2)
  (puthash 'bar "foo" hash3)
  (puthash 'bar "foo" hash4)
  (puthash 'baz hash3 hash1)
  (puthash 'baz hash4 hash2)
  (hash-equal hash1 hash2))

We could use hash-table-test to compare predicates, perhaps
dependent on the presence of a 'compare-tests flag?

Best,

Joseph




Acknowledgement sent to Joseph Turner <joseph@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#63671; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Wed, 24 May 2023 17:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.