From: Christopher Dimech <dimech@gmx.com>
To: Eli Zaretskii <eliz@gnu.org>, Drew Adams <drew.adams@oracle.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Locating file via load-path
Date: Fri, 9 Aug 2024 18:51:32 +0200 [thread overview]
Message-ID: <trinity-d6e6719c-3e43-4044-8ea6-c8a6f5694132-1723222292009@3c-app-mailcom-bs09> (raw)
In-Reply-To: <DS7PR10MB523247B9BE096B84C51A599CF3BA2@DS7PR10MB5232.namprd10.prod.outlook.com>
> Sent: Saturday, August 10, 2024 at 4:19 AM
> From: "Drew Adams" <drew.adams@oracle.com>
> To: "Eli Zaretskii" <eliz@gnu.org>, "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
> Subject: RE: [External] : Re: Locating file via load-path
>
> > > > Why cl-pushnew ?
> > >
> > > Either is OK. The doc of `add-to-list' says:
> > >
> > > you are usually better off using `push' or `cl-pushnew'.
> >
> > Talk about citation out of context. The full quotation is
> >
> > This is handy to add some elements to configuration variables,
> > but please do not abuse it in Elisp code, where you are usually
> > better off using ‘push’ or ‘cl-pushnew’.
> >
> > IOW, don't (ab)use add-to-list if all you need is to add a new element
> > to some list of elements. add-to-list is for adding path elements to
> > variables like load-path.
>
> That text says use it mainly for user ("configuration")
> variables, not generally for Lisp code. And it neither
> says nor suggests anything about lists of path elements.
>
> > > It doesn't say why, and neither does the Elisp manual.
> >
> > Oh, yes, it does, see above.
>
> No, there's nothing about "why" above.
>
> May I humbly encourage you to review the following
> mails in this very list from Stefan Monnier on the
> subject, back in 2013, during his tenure as the
> Emacs maintainer (thread "Is add-to-list supposed
> to work when lexical-binding is t?"):
In such case add-to-list has to the potential for misleading code.
There’s an argument to be made that functions like add-to-list
should be robust enough to handle a variety of scenarios, not just
for modifying configuration variables like load-path. There should
be some robustness expectations rather than expecting users not to
abuse it. The function should be versatile and resistant to misuse.
If developers could use more appropriate list operations when dealing
with general-purpose list manipulation (including for load-path), the
better life would be for everybody.
> Not in chronological order, but perhaps in order of
> relevance and understanding for us, here:
>
> https://mail.gnu.org/archive/html/help-gnu-emacs/2013-06/msg00096.html
>
> https://mail.gnu.org/archive/html/help-gnu-emacs/2013-06/msg00064.html
>
> https://mail.gnu.org/archive/html/help-gnu-emacs/2013-06/msg00124.html
>
> https://mail.gnu.org/archive/html/help-gnu-emacs/2013-06/msg00188.html
>
> In particular, this bit summarizes _WHY_ he added that
> "usually better off using ‘push’ or ‘cl-pushnew’" [in
> Lisp code] text to the doc string (in Emacs 24):
>
> "The warning was added because add-to-list is a
> frequent use-case where Elisp code presumes
> dynamic binding."
>
> And:
>
> > Unless you're knee-deep in the internals of the language,
> > the difference between `cl-pushnew' and `add-to-list' is
> > so obscure as to be incomprehensible.
>
> "Agreed. I never liked add-to-list, and now I really
> know why ... other than by ad-hoc handling the case
> where the first arg is passed via quoting, the
> byte-compiler" [is pretty hopeless for add-to-list]
>
>
next prev parent reply other threads:[~2024-08-09 16:51 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-08 16:59 Locating file via load-path Heime
2024-08-08 18:33 ` Eli Zaretskii
[not found] ` <DDYXKsMNq=5FPzC2iDOfz6ETUaC7H-vuOcAXfNk2GimDjscOHbeHzG6k=5FZi7IY3HMwckcFmb=5FFSBn9rYaDxKDD5OSzLlcq7SJksWLI=5FczwUvc=3D@protonmail.com>
[not found] ` <Q1xAU81Xn9UZt8V95EDVRqwUvUNfmlk3rU-arBrbQ8CMmh7IpXd3xgEt4qZwH3zJ7l989GxHrEb=5F3R9eJ-sd1SoofwcnBVpnYWjxU5ni1TE=3D@protonmail.com>
2024-08-08 19:09 ` Heime
2024-08-08 19:15 ` Heime
2024-08-08 19:42 ` Heime
2024-08-08 19:51 ` [External] : " Drew Adams
[not found] ` <dfOBGQnGfe22rKYsEePcBLU2WWYEt5JBoyDuis=5FJnnmM90x5w2lHn6cWlp61yG63OxKWTfWP0=5FBk9F6-836xfAfBbbx6gOHzOTAvMzxhnL8=3D@protonmail.com>
[not found] ` <DS7PR10MB5 23233B5F43170D4D4328BCBF3B92@DS7PR10MB5232.namprd10.prod.outlook.com>
[not found] ` <UrKx-9HV=5FVLIwsNkymmTbUk5GX6jduusTCwQVBacu2z8PK2QT1SLrG30lyq7J5PaKayGO7XcU5bq1R-pGMPgQtZWYI0dxXnrxj6vfgrXXt8=3D@protonmail.com>
2024-08-08 20:07 ` Heime
2024-08-08 21:25 ` Drew Adams
2024-08-08 21:59 ` Heime
2024-08-08 22:30 ` Drew Adams
2024-08-08 22:35 ` Heime
2024-08-09 5:31 ` Eli Zaretskii
2024-08-09 16:19 ` Drew Adams
2024-08-09 16:51 ` Christopher Dimech [this message]
2024-08-09 17:39 ` Eli Zaretskii
2024-08-09 19:52 ` Arash Esbati
2024-08-10 5:39 ` Eli Zaretskii
2024-08-11 13:35 ` Arash Esbati
2024-08-11 14:11 ` Eli Zaretskii
2024-08-11 19:49 ` Arash Esbati
2024-08-11 21:07 ` [External] : " Drew Adams
2024-08-11 21:24 ` Christopher Dimech
2024-08-09 5:28 ` [External] : " Eli Zaretskii
2024-08-09 5:21 ` Eli Zaretskii
2024-08-09 5:20 ` Eli Zaretskii
2024-08-08 18:38 ` Bruno Barbier
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=trinity-d6e6719c-3e43-4044-8ea6-c8a6f5694132-1723222292009@3c-app-mailcom-bs09 \
--to=dimech@gmx.com \
--cc=drew.adams@oracle.com \
--cc=eliz@gnu.org \
--cc=help-gnu-emacs@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.
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).