guile-user
[Top][All Lists]
Advanced

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

Equality and hashing for new datatypes


From: Philip McGrath
Subject: Equality and hashing for new datatypes
Date: Wed, 21 Jun 2023 18:25:29 -0400

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-Miscellany.html
[2]: https://lists.gnu.org/archive/html/info-gnu/2023-05/msg00005.html
[3]: 
https://docs.racket-lang.org/reference/Equality.html#%28part._.Implementing_.Equality_for_.Custom_.Types%29
[4]: https://cisco.github.io/ChezScheme/csug9.5/objects.html#./objects:h14

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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