From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: dolist considered harmful
Date: Tue, 30 Oct 2018 21:31:18 +0200 [thread overview]
Message-ID: <83ftwnjkop.fsf@gnu.org> (raw)
In-Reply-To: <jwvwopzfftn.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Tue, 30 Oct 2018 14:39:46 -0400)
> From: Stefan Monnier <monnier@IRO.UMontreal.CA>
> Date: Tue, 30 Oct 2018 14:39:46 -0400
>
> - The docstring is incomprehensible:
>
> Loop over a list.
> Evaluate BODY with VAR bound to each car from LIST, in turn.
> Then evaluate RESULT to get return value, default nil.
>
> I don't know how to loop over a list.
I think the rest of the doc string explains how.
> "evaluate" is unclear (is it passed to `eval`? Then why not say it?
What "evaluation" is, is described in the section "Evaluation" of the
ELisp manual.
> Also, in which order?
It says "each car from LIST, in turn". I think this answers your
question.
> How does RESULT communicate the return value?
> Is it RESULT which defaults to nil or the return value?
> If the return value, then when does it default to nil?
I think this is clear from the text, I'm unsure what confused you.
> - The docstring says nothing of what happens when LIST is not a list,
> yet a quick grep shows that most uses of dolist use for LIST a simple
> variable rather than a list. What gives?
There's no contradiction here.
> Since it can only be used when we're 100% sure that LIST is a LIST,
> (and who can be sure of such a thing in a dynamic language like Emacs
> Lisp), I think we'd be better off deprecating it and changing all uses
> of dolist with a clear while+cdr loop that everyone can understand.
Patches welcome.
next prev parent reply other threads:[~2018-10-30 19:31 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-30 18:39 dolist considered harmful Stefan Monnier
2018-10-30 19:31 ` Eli Zaretskii [this message]
2018-10-30 23:24 ` Jay Kamat
2018-10-30 23:29 ` Noam Postavsky
2018-10-30 23:47 ` Drew Adams
2018-10-31 22:02 ` Garreau, Alexandre
2018-10-31 22:44 ` Noam Postavsky
2018-10-31 23:01 ` Garreau, Alexandre
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=83ftwnjkop.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--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).