unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Juri Linkov <juri@linkov.net>
Cc: Christopher Wellons <wellons@nullprogram.com>, 16206@debbugs.gnu.org
Subject: bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes
Date: Mon, 23 Apr 2018 15:09:37 -0400	[thread overview]
Message-ID: <jwvefj5iw7r.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <874lk26fjt.fsf@mail.linkov.net> (Juri Linkov's message of "Mon,  23 Apr 2018 01:29:25 +0300")

>   (let ((count 10))
>     (dotimes (i count count) (print i)))

I don't disagree with you: I think this 3rd field is a misfeature
of dotimes.  But IIRC there is code out there which uses it.
It can be marginally useful in cases such as:

    (dotimes (i (read-number "Nb of entries: ") i)
      ...blabla...)

which would otherwise need to explicitly bind the output of
`read-number` to a variable, hence something like:

    (let ((n (read-number "Nb of entries: ")))
      (dotimes (i n)
        ...blabla...)
      n)

But basically, IIRC last time this question came up we kept the current
behavior because while this shed's color is not great, at least it's the
same color as Common Lisp's.

BTW, you say:

> it's clearer to use `count'
>
>   (let ((count 10))
>     (dotimes (i count count) (print i)))

but I really don't like the way the overall output is "hidden" in this
third field; it gives a very unusual order of execution.
I personally consider:

   (let ((count 10))
     (dotimes (i count) (print i))
     count)

to be much more clear.  Which is why I think the current behavior of
complaining when the third field is used (except in the very rare case
where the third field refers to the iteration variable) is a fairly
good compromise.


        Stefan





  reply	other threads:[~2018-04-23 19:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-20 21:06 bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes Christopher Wellons
2013-12-23  2:48 ` Stefan Monnier
2018-04-22 22:29   ` Juri Linkov
2018-04-23 19:09     ` Stefan Monnier [this message]
2018-04-24 19:21       ` Juri Linkov
2018-04-24 21:13         ` Stefan Monnier
2018-04-25  0:11           ` Michael Heerdegen
2018-04-25 19:31           ` Juri Linkov
2018-04-26  3:43             ` Stefan Monnier
2018-04-28 20:21               ` Juri Linkov
2020-09-30 18:31               ` bug#31232: " Lars Ingebrigtsen
2018-04-25  2:33         ` Eli Zaretskii

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=jwvefj5iw7r.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=16206@debbugs.gnu.org \
    --cc=juri@linkov.net \
    --cc=wellons@nullprogram.com \
    /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).