public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
From: Panicz Maciej Godek <godek.maciek@gmail.com>
To: kawa@sourceware.org
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: <CAMFYt2Y8Pn9nxmr6U9DBNH+pkKnt8H1-pdgO3hDWgB3C-N3=5w@mail.gmail.com> (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:

https://github.com/panicz/grasp-android/blob/master/stages/stage6/src/org/scheme/parse.scm

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to='CAMFYt2Y8Pn9nxmr6U9DBNH+pkKnt8H1-pdgO3hDWgB3C-N3=5w@mail.gmail.com' \
    --to=godek.maciek@gmail.com \
    --cc=kawa@sourceware.org \
    /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.
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).