[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#16206: 24.3; Incorrect unused variable byte-compiler warning in doti
From: |
Stefan Monnier |
Subject: |
bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes |
Date: |
Mon, 23 Apr 2018 15:09:37 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> (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
- bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes, Juri Linkov, 2018/04/22
- bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes,
Stefan Monnier <=
- bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes, Juri Linkov, 2018/04/24
- bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes, Stefan Monnier, 2018/04/24
- bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes, Michael Heerdegen, 2018/04/24
- bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes, Juri Linkov, 2018/04/25
- bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes, Stefan Monnier, 2018/04/25
- bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes, Juri Linkov, 2018/04/28
- bug#16206: 24.3; Incorrect unused variable byte-compiler warning in dotimes, Eli Zaretskii, 2018/04/24