From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Philip McGrath <philip@philipmcgrath.com>
Newsgroups: gmane.lisp.guile.user
Subject: Re: Equality and hashing for new datatypes
Date: Thu, 22 Jun 2023 18:45:54 -0400
Message-ID: <2803364.tdWV9SEqCh@bastet>
References: <3759578.e9J7NaK4W3@bastet>
 <01fa3142-02d8-9bb0-9dfd-5b233aa57bbf@gmail.com>
Mime-Version: 1.0
Content-Type: multipart/signed; boundary="nextPart3095218.irdbgypaU6";
 micalg="pgp-sha512"; protocol="application/pgp-signature"
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="8119"; mail-complaints-to="usenet@ciao.gmane.io"
To: guile-user <guile-user@gnu.org>, Taylan Kammer <taylan.kammer@gmail.com>
Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Fri Jun 23 00:46:48 2023
Return-path: <guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org>
Envelope-to: guile-user@m.gmane-mx.org
Original-Received: from lists.gnu.org ([209.51.188.17])
	by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
	(Exim 4.92)
	(envelope-from <guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org>)
	id 1qCT4g-0001qf-TX
	for guile-user@m.gmane-mx.org; Fri, 23 Jun 2023 00:46:48 +0200
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <guile-user-bounces@gnu.org>)
	id 1qCT48-00087w-Co; Thu, 22 Jun 2023 18:46:12 -0400
Original-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 <philip@philipmcgrath.com>)
 id 1qCT46-00087f-Rn
 for guile-user@gnu.org; Thu, 22 Jun 2023 18:46:10 -0400
Original-Received: from wout3-smtp.messagingengine.com ([64.147.123.19])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <philip@philipmcgrath.com>)
 id 1qCT42-0000YW-5P
 for guile-user@gnu.org; Thu, 22 Jun 2023 18:46:10 -0400
Original-Received: from compute2.internal (compute2.nyi.internal [10.202.2.46])
 by mailout.west.internal (Postfix) with ESMTP id C24153200392;
 Thu, 22 Jun 2023 18:46:02 -0400 (EDT)
Original-Received: from mailfrontend2 ([10.202.2.163])
 by compute2.internal (MEProxy); Thu, 22 Jun 2023 18:46:02 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 philipmcgrath.com; h=cc:content-type:content-type:date:date:from
 :from:in-reply-to:in-reply-to:message-id:mime-version:references
 :reply-to:sender:subject:subject:to:to; s=fm2; t=1687473962; x=
 1687560362; bh=Zw0tU8HL4HXSDa2AagydH4R7RxANEAShy0Agw6iMtbs=; b=h
 KT/8j/rtLDbrQmwaRi8fv4G8+OD6xGbuZ7AExpr2qT+swDlMx/xTbZO/5loX/xdO
 2hMmQtKf8b8sSo0qZgv6UaJYp1+zKua0HbhaJ8HF0j7Kr+Teo+ZrIbKgbn0nzq8y
 gG6VYqnp4x0MpY2W8Yr6yYU3VRKrkRP57lkZ/IONozw4/34WS4+j9iGdOiC+h5fV
 liLZaXGjH7LjqTJwWU/OeuUaKFpWlR7AlHpV6LywxkaFRAVBPBtN6p6JDd97o96a
 G3d35mejaqyk8jDrXTTw2K8ksEF75JncypeFbe8DxlymPiOj0HeqT0AJq7hmpyzm
 jMizAk/J2ZJNkvnQM1Oww==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:content-type:content-type:date:date
 :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to
 :message-id:mime-version:references:reply-to:sender:subject
 :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender
 :x-sasl-enc; s=fm2; t=1687473962; x=1687560362; bh=Zw0tU8HL4HXSD
 a2AagydH4R7RxANEAShy0Agw6iMtbs=; b=q4fUoP5b2A6kO/HDzsTHMHrpaIhVt
 4CnPFbGUfq4txaViZ7O0388lM3qWasncsXP4S14uspWJTOpVzUksMVHhWNpiMnpR
 YEhkD9uGmVLc7mtC8nffo0BxasPcIurCd0pLJE0TnMdG2ExkdmKu7VyYQh44cRVe
 kJamC6KbivH5iAl4suoULQz+lM6bma3zc3apxpsqDp6v9MJ/8BSHqRx+jnJtWlXG
 a44zABQ4tGFeXwl8ZMNUOMTCixAy7tL9PN+YPpxPQtirXoesjhWa7tWOcfXo59lO
 cMzEMvtGq6t0++MDH3+EjUfEA0R63iu2mB2c0T7SHcvetgg5ppYM10TXQ==
X-ME-Sender: <xms:Ks-UZGtog0FWYRN60ctkiaDwrv9AarJnTpONG7zfAZ6K0zc6vZx2Jg>
 <xme:Ks-UZLezXUnkBeDGM7zYfIdo-iv6Spsb3vNKVa_AWgZHtzWlVZwGB-nfykA8yTr_L
 tAAgmKj4s2wFIeerDQ>
X-ME-Received: <xmr:Ks-UZBxHcMIySkUOJ043Gtau72N_GggyXLi5AO7B6da7YHLoIkBFfxpuWJei5zug4Qw9bNR7GhMGpjY3qhbStrGAOuzn3EABa81GmA>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgeegvddguddvucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne
 goufhushhpvggtthffohhmrghinhculdegledmnecujfgurhephffvufffkfgjfhggtges
 ghdtreertddtvdenucfhrhhomheprfhhihhlihhpucfotgfirhgrthhhuceophhhihhlih
 hpsehphhhilhhiphhmtghgrhgrthhhrdgtohhmqeenucggtffrrghtthgvrhhnpeekgeff
 fedtjefhleffgfegueevudeijefhtdduteelgffhjeduvedthfelvdevudenucffohhmrg
 hinhepghhnuhdrohhrghdprhgrtghkvghtqdhlrghnghdrohhrghdpghhithhhuhgsrdhi
 ohenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehphh
 hilhhiphesphhhihhlihhpmhgtghhrrghthhdrtghomh
X-ME-Proxy: <xmx:Ks-UZBPbZMQuX8BCQditp86w9WYKVnicnf18cNJlrXRuEJ3SezbEfQ>
 <xmx:Ks-UZG8djOdDxb21l04_PgEmg3KOKBcKS9jJDomFFuem3IkoMvUITA>
 <xmx:Ks-UZJXeVF6Bsj6WWZQMWBPH2LvuvV8HoE4pwG8FD84opKFEYqlzmw>
 <xmx:Ks-UZKbLZvdnzYLsn09WZZBuLzKUHEXUulzfldOoNpCjPVs3WN0xRA>
Feedback-ID: i2b1146f3:Fastmail
Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu,
 22 Jun 2023 18:46:01 -0400 (EDT)
In-Reply-To: <01fa3142-02d8-9bb0-9dfd-5b233aa57bbf@gmail.com>
Received-SPF: pass client-ip=64.147.123.19;
 envelope-from=philip@philipmcgrath.com; helo=wout3-smtp.messagingengine.com
X-Spam_score_int: -27
X-Spam_score: -2.8
X-Spam_bar: --
X-Spam_report: (-2.8 / 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,
 RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-BeenThere: guile-user@gnu.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: General Guile related discussions <guile-user.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/guile-user>,
 <mailto:guile-user-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/guile-user>
List-Post: <mailto:guile-user@gnu.org>
List-Help: <mailto:guile-user-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guile-user>,
 <mailto:guile-user-request@gnu.org?subject=subscribe>
Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org
Original-Sender: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org
Xref: news.gmane.io gmane.lisp.guile.user:19059
Archived-At: <http://permalink.gmane.org/gmane.lisp.guile.user/19059>

--nextPart3095218.irdbgypaU6
Content-Transfer-Encoding: 7Bit
Content-Type: text/plain; charset="us-ascii"; protected-headers="v1"
From: Philip McGrath <philip@philipmcgrath.com>
Subject: Re: Equality and hashing for new datatypes
Date: Thu, 22 Jun 2023 18:45:54 -0400
Message-ID: <2803364.tdWV9SEqCh@bastet>
In-Reply-To: <01fa3142-02d8-9bb0-9dfd-5b233aa57bbf@gmail.com>
MIME-Version: 1.0

On Thursday, June 22, 2023 7:33:06 AM EDT Taylan Kammer wrote:
> On 22.06.2023 00:25, Philip McGrath wrote:
> > Hi,
> > 
> > What is the recommended way for a library to customize `equal?` and
> > `equal?` -based hashing for new datatypes it defines?
> > 
> > I know from [1] that `equal?` can be customized using GOOPS; however, some
> > projects do not use GOOPS (e.g. [2]), so it would seem more friendly for a
> > generic library to avoid it. Also, it is not clear if the same mechanism
> > is
> > even an option for customizing `equal-hash` to match `equal?`.
> > 
> > I'm looking for something like Racket's `gen:equal+hash` [3] or Chez
> > Scheme's `record-equal-procedure` and `record-hash-procedure` [4].
> > 
> > This came up while I was working on a portable version of the immutable
> > hash-table implementations from Racket-on-Chez.
> > 
> > -Philip
> > 
> > [1]:
> > https://www.gnu.org/software/guile/manual/html_node/GOOPS-Object-Miscella
> > ny.html [2]:
> > https://lists.gnu.org/archive/html/info-gnu/2023-05/msg00005.html [3]:
> > https://docs.racket-lang.org/reference/Equality.html#%28part._.Implementi
> > ng_.Equality_for_.Custom_.Types%29 [4]:
> > https://cisco.github.io/ChezScheme/csug9.5/objects.html#./objects:h14
> Hi Philip,
> 
> You can use SRFI 69 hash tables in Guile.  This library offers a way to
> specify the equality and hash procedures that should be used by a hash
> table, e.g.:
> 
> [...]
> 
> Note that this doesn't affect the behavior of the standard 'equal?'
> procedure, it only affects the SRFI 69 hash table operations on the created
> hash table.
> 
> I currently don't remember whether Guile's own non-portable hash table
> library supports the same feature.  It probably does in some way.
> 

Thanks, but this is the opposite of what I want to do. The library I'm porting 
already supports creating tables with custom equality and hashing functions. 
What I'm trying to do is make the standard `equal?` procedure recognize when 
two of my table values are semantically the same even if internal 
implementation details differ.

(Note also that SRFI 69 and other libraries provide *mutable* hash tables. The 
Racket-on-Chez library I'm porting provides immutable hash tables, more 
properly Hash Array Mapped Tries, as made famous by Clojure.)

-Philip
--nextPart3095218.irdbgypaU6
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part.
Content-Transfer-Encoding: 7Bit

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEE9GWrrNY3rqwUFVXPygNjjfo/HHoFAmSUzyIACgkQygNjjfo/
HHr1MhAAttNg+FxWXvr7cPq/TUXv4tG4CoxJc98p2xBXrWp3LK88V2NxjcSdHli5
qVcFWLds/JabqrVihYMfOKw5kEU4SCswtLN+NnfG3oyDIpdhU/z4Vl2YieLkAGv5
/ki/i4+ePNoV6oInVmpl7kY07aZ25kmtnlyDyTghsZMMKqO9eOm8jCFZRHU++oEb
VDl/pYWnrjJZ9CIeNyd8i0526WpI2xJUv8pMEY5YcsGx+i/e+HbAaNdoyJgQLVJ7
6tkecZ/5llygaiAIMVt1WL34JG+TK+84VnufW96JS+5KcegwMGSiHQb8dThoRBo1
TcNVj+DvJxQfY08iSiuXu4BuOivj1jngSR+hZbuUuMwg7sJNGlGCp4WzHBffFzd1
Tr4PDkXq+7GyJBnlxZziJQX/+hsHC1uVrOFLrznwndlUm/C3CkJNqBcEgvoxqMjg
onao9GDqTs//dBxdXumpKWR/EGkBTQi86sVb6tXWYHikKrdYKxyW9aRK70YWU9C8
VuF0VyU+OXXN29eAsKClVGBxCSFftKo4Ck0QA4/biq57bCi6D0Yh6XyGfjD2yobN
SjjDl/TDFx3blaegYkNzMh6KJslo2y/wnDfwO7hq6jrpOq7pIWyr5ajIB+/W2U4F
8+o1HcD4Iif3GyhIvwe1kIEVrhvtqs/MHGZHKxjYmjsuhlSp1os=
=CFyM
-----END PGP SIGNATURE-----

--nextPart3095218.irdbgypaU6--