GNU bug report logs -
#47992
27; 28; Phase out use of `equal` in `add-hook`, `remove-hook`
Previous Next
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
> > But what advantage would these offer,
> > compared to standard naming?
>
> By "standard naming" you mean "define a function,
> and then use it in `add-hook'?" Experience shows
> that people avoid doing so (for various reason),
> so creating a new form to cater to this use case
> makes sense.
FWIW, I disagree. There's no real need for such
a "new form".
I think the use case you've imagined for it is a
s t r e t c h . Users will just as likely avoid
making any of your new forms as they avoid named
functions now.
The "various reasons" amount to laziness (which
is often the right approach), and that will be
the same reason for not naming lambdas in the
new way you envision. There's a reason lambdas
are anonymous functions.
Here's maybe another hint that it isn't needed:
Has anyone ever requested such a feature?
And if there really were such a need, you could
just check for non-nil `eq'uality of a lambda's
doc string, instead of adding yet another "new
form" that will likely ~never be used.
And even that feature - using a doc string with
a lambda - is rarely used. As the doc string
of `lambda' itself says:
But documentation strings are usually not
useful in nameless functions.
Let's not add another ~useless "new form" for
lambdas. They already have a doc string, which
I'm guessing is as much a name as what you have
in mind.
If you really want to test with `eq', just use
`eq' together with function `documentation'.
That'll save you implementing the same kind of
thing for yet another "name". Same test: (1)
are both "names" present (non-nil), and (2) if
if so, are they `eq'?
And the same problem will persist: few will
ever bother to provide such a "name", even if
it might help them with `add|remove-hook'.
You have a solution in search of a problem, I
think. Users just learn the hard way (but the
doc of `add|remove-hook' could be improved to
help them learn) that they don't want to use
lambdas as hook functions.
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.