GNU bug report logs - #47992
27; 28; Phase out use of `equal` in `add-hook`, `remove-hook`

Previous Next

Package: emacs;

Reported by: Daniel Mendler <mail <at> daniel-mendler.de>

Date: Sat, 24 Apr 2021 12:12:01 UTC

Severity: normal

Tags: fixed

Fixed in version 28.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Daniel Mendler <mail <at> daniel-mendler.de>
To: Drew Adams <drew.adams <at> oracle.com>, "47992 <at> debbugs.gnu.org" <47992 <at> debbugs.gnu.org>
Cc: "monnier <at> iro.umontreal.ca" <monnier <at> iro.umontreal.ca>, "jakanakaevangeli <at> chiru.no" <jakanakaevangeli <at> chiru.no>
Subject: bug#47992: [External] : bug#47992: 27; 28; Phase out use of `equal` in `add-hook`, `remove-hook`
Date: Sat, 24 Apr 2021 22:23:50 +0200
On 4/24/21 10:12 PM, Drew Adams wrote:
> So instead of just advising users not to use lambda forms
> (which makes sense), you'd make it no longer work at all
> for interpreted lambda forms (except rare cases where
> they might actually be `eq' - e.g., same list structure)?

I agree that it makes sense to use symbols in case you want to add a 
plain function as hook. However often you want to add closures; 
`minibuffer-with-setup-hook`, `set-transient-map` and `eval-after-load` 
are examples where this happens. In order to improve the support for 
closures as hooks, this change is necessary.

It is not reasonable to require every `add-hook` user, who wants to add 
a closure, to introduce a symbol indirection. This is neither obvious 
nor easy. Even a very commonly used macro like 
`minibuffer-with-setup-hook` got this wrong.

Furthermore I would argue there are no plausible scenarios where you 
want to add a closure or lambda as hook and then remove or add it again 
afterwards, but not using the identical object, but only an object which 
is `equal`.

This is more than enough motivation for a change to `eq`.

Daniel




This bug report was last modified 3 years and 323 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.