unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Lars Ingebrigtsen <larsi@gnus.org>
To: Daniel Mendler <mail@daniel-mendler.de>
Cc: 47992@debbugs.gnu.org, monnier@iro.umontreal.ca,
	jakanakaevangeli@chiru.no
Subject: bug#47992: 27; 28; Phase out use of `equal` in `add-hook`, `remove-hook`
Date: Sun, 02 May 2021 11:09:48 +0200	[thread overview]
Message-ID: <87mttdh57n.fsf@gnus.org> (raw)
In-Reply-To: <a9335e6c-e261-59a0-d59a-7dbb70d6dba6@daniel-mendler.de> (Daniel Mendler's message of "Sat, 24 Apr 2021 14:11:48 +0200")

Daniel Mendler <mail@daniel-mendler.de> writes:

> It would be good to change `add/remove-hook` such that it only relies
> on `eq` to test hook equality. Then the symbol indirection workarounds
> can be avoided.
>
> However making such a change directly can lead to subtle
> breakage. Perhaps one could introduce some deprecation behavior first,
> before making the final change to `eq`.  If a hook is added/removed
> and the added/removed object is not found via `eq` but found via
> `equal`, show a deprecation warning?

There are two issues here:

1) Should `add/remove-hook' even attempt to do uniqueness checks when
adding/removing things that aren't symbols (or more generally, eq-able
things), and

2) Should `add-hook' disallow adding such things?

Today, it's super common for people to say

(add-hook 'some-hook (lambda () ...))

in their .emacs files.  This isn't because they have any expectation
that add-hook does this uniquely, or that remove-hook will work, but
because that's just what they think they should do.

So I think 2) is out of the question -- we can't deprecate this, and we
can't issue any warnings about doing it this way.  (Even if it's
"wrong" -- it's just not feasible to disallow this.)

And since 2) isn't possible, I don't really think 1) is possible
either.  People do `M-x eval-buffer' their .emacs files, and since we're
using `equal' here, this happens to work -- almost by accident.

(If they change the lambda, then they get two instances of the lambda in
the hook, so it's "wrong", but it's so common.)

So I'm not sure I see any way forward with this.  Would adding a new
pair of functions (that are `eq' only) help in any way?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





  parent reply	other threads:[~2021-05-02  9:09 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-24 12:11 bug#47992: 27; 28; Phase out use of `equal` in `add-hook`, `remove-hook` Daniel Mendler
2021-04-24 20:12 ` bug#47992: [External] : " Drew Adams
2021-04-24 20:23   ` Daniel Mendler
2021-04-24 21:20     ` Drew Adams
2021-04-24 21:34       ` Daniel Mendler
2021-04-24 22:30   ` Stefan Monnier
2021-04-24 22:38     ` Daniel Mendler
2021-04-24 23:04       ` Stefan Monnier
2021-04-24 23:38         ` Daniel Mendler
2021-04-25  1:16         ` Drew Adams
2021-04-25  3:08           ` Stefan Monnier
2021-04-25  4:57             ` Drew Adams
2021-04-25 13:52               ` Stefan Monnier
2021-04-25  1:16       ` Drew Adams
2021-04-25  1:23     ` Drew Adams
2021-04-25  3:10       ` Stefan Monnier
2021-04-25  4:57         ` Drew Adams
2021-04-25 10:33           ` Daniel Mendler
2021-04-25 13:56           ` Stefan Monnier
2021-05-02  9:09 ` Lars Ingebrigtsen [this message]
2021-05-02 10:37   ` Daniel Mendler
2021-05-03  8:50     ` Lars Ingebrigtsen
2021-07-06 14:44     ` Olivier Certner
     [not found]   ` <877di6udfy.fsf@web.de>
2021-07-04  1:09     ` Lars Ingebrigtsen
2021-07-04  2:35       ` Michael Heerdegen
2021-07-04  2:56         ` Lars Ingebrigtsen
2021-07-04  4:28           ` Michael Heerdegen
2021-07-04 13:36             ` Lars Ingebrigtsen
2021-07-04 17:08               ` bug#47992: [External] : " Drew Adams
2021-07-04 22:45                 ` Michael Heerdegen
2021-07-05 12:39                 ` Lars Ingebrigtsen
2021-07-06  1:48             ` Richard Stallman
2021-07-06  2:37               ` bug#47992: [External] : " Drew Adams
2021-07-06  3:21                 ` Michael Heerdegen
2021-07-07 23:57                 ` Richard Stallman
2021-07-06  9:46               ` Arthur Miller
2021-07-07 23:57                 ` Richard Stallman
2021-07-08  2:11                   ` Arthur Miller
2021-07-04 23:15       ` Michael Heerdegen

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=87mttdh57n.fsf@gnus.org \
    --to=larsi@gnus.org \
    --cc=47992@debbugs.gnu.org \
    --cc=jakanakaevangeli@chiru.no \
    --cc=mail@daniel-mendler.de \
    --cc=monnier@iro.umontreal.ca \
    /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 public inbox

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

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