all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Adam Porter <adam@alphapapa.net>
To: 32503@debbugs.gnu.org
Subject: bug#32503: 26.1; Byte-compiled functions don't hash consistently
Date: Wed, 22 Aug 2018 14:00:28 -0500	[thread overview]
Message-ID: <CAO_b3FV+BOeguJU+UFpfo6VnrJ9Q5ympyeX61RHaKQhtcyhfug@mail.gmail.com> (raw)

I noticed that byte-compiled functions don't hash consistently.  Here's
an ECM from Noam Postavsky
<https://github.com/skeeto/emacs-memoize/pull/10#issuecomment-415066682>:

    (let ((obj1 (byte-compile (lambda (x) x)))
          (obj2 (byte-compile (lambda (x) x))))
      (list (equal obj1 obj2)
            (eq obj1 obj2)
            (= (sxhash obj1)
               (sxhash obj2))))
    ;=> (t nil nil)

According to "(elisp) Defining Hash":

    If two objects OBJ1 and OBJ2 are equal, then ‘(sxhash OBJ1)’ and
    ‘(sxhash OBJ2)’ are the same integer.

This makes it impossible to use byte-compiled functions as keys or parts
of keys in hash tables.  A workaround is to `prin1-to-string` the
byte-compiled function and use that as the key.

Thanks.





             reply	other threads:[~2018-08-22 19:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-22 19:00 Adam Porter [this message]
2018-08-23  1:42 ` bug#32503: 26.1; Byte-compiled functions don't hash consistently Tom Tromey
  -- strict thread matches above, loose matches on Subject: below --
2020-01-04  1:49 bug#38912: 27.0.60; PDumper meets segmentation fault when evil is loaded NiwTinray via Bug reports for GNU Emacs, the Swiss army knife of text editors
2020-01-04  9:17 ` Eli Zaretskii
     [not found]   ` <D1473DD8-48F8-4204-80B5-BE6396B8B668@icloud.com>
2020-01-05 18:45     ` Eli Zaretskii
2020-01-06 17:10       ` Daniel Colascione
2020-03-05  7:14         ` Eli Zaretskii
2020-03-09  2:15           ` Daniel Colascione
2020-03-09  3:26             ` Eli Zaretskii
2021-06-24 16:30               ` bug#32503: 26.1; Byte-compiled functions don't hash consistently Lars Ingebrigtsen

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=CAO_b3FV+BOeguJU+UFpfo6VnrJ9Q5ympyeX61RHaKQhtcyhfug@mail.gmail.com \
    --to=adam@alphapapa.net \
    --cc=32503@debbugs.gnu.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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.