GNU bug report logs -
#16206
24.3; Incorrect unused variable byte-compiler warning in dotimes
Previous Next
Full log
View this message in rfc822 format
> (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
This bug report was last modified 4 years and 236 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.