public inbox for
 help / color / mirror / Atom feed
From: Panicz Maciej Godek <>
Subject: Rationale for providing "equal?"-like "equals" method for gnu.lists.Pair
Date: Wed, 5 Jan 2022 09:00:35 +0100	[thread overview]
Message-ID: <> (raw)

I'd like to know what the rationale for providing the "equals" method with
"structural identity" is.

I found it problematic in at least one respect: I have decided to use
Java's weak hash tables to represent "properties" attached to cons-cells.
However, since those hash tables rely on the Object's "equals" method, the
table is unable to distinguish between two different cons-cells that point
to the same object.

I came up with two solutions to this problem. The first one was patching
the implementation of Pair, simply by removing the implementations of the
equals method is LList and its subclasses. (IIRC there were some failing
tests after the change, but I didn't investigate further)

The second solution was simply subclassing gnu.lists.Pair and overriding
its equals and hashCode methods, as I did here:

It works, but the "equal?" semantics for cons-cells doesn't seem right to
me, so I wonder what was the reason for providing it, and whether there is
some code which relies on it

                 reply	other threads:[~2022-01-05  8:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='' \ \ \

* 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.
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).