for (int i : range(10)) {
// ...
}
// Is equivalent to
for (int i = 0; i < 10; ++i) {
// ...
}
for (int : range(10)) {
// ...
}
to not even dereference the implicit iterator.
Obviously there are various ways around this, in particular using the traditional for loop does not generate a warning.
On 4 June 2016 at 04:27, Nevin Liber <ne...@eviloverlord.com> wrote:On 3 June 2016 at 05:37, <schreiber...@gmail.com> wrote:--
Obviously there are various ways around this, in particular using the traditional for loop does not generate a warning.Yes, and IMO it doesn't come up often enough to warrant a language change.Nevin ":-)" Liber <mailto:ne...@eviloverlord.com> +1-847-691-1404different styles i guess but it definitely comes up enough for me. and i think will for even more too when the range ts is accepted and the std:: equivalent of boost::irange is preferred to for(..; ..; ..).
but really i think a wildcard symbol for unused variables (ala googletest, python, etc...) would be best general solution to this and much more.
On Saturday, June 4, 2016 at 7:56:50 AM UTC-4, Sam Kellett wrote:On 4 June 2016 at 04:27, Nevin Liber <ne...@eviloverlord.com> wrote:On 3 June 2016 at 05:37, <schreiber...@gmail.com> wrote:--
Obviously there are various ways around this, in particular using the traditional for loop does not generate a warning.Yes, and IMO it doesn't come up often enough to warrant a language change.Nevin ":-)" Liber <mailto:ne...@eviloverlord.com> +1-847-691-1404different styles i guess but it definitely comes up enough for me. and i think will for even more too when the range ts is accepted and the std:: equivalent of boost::irange is preferred to for(..; ..; ..).
I have written, I'm going to go with thousands of `for` loops. Pre-range for loops.
I cannot recall a single time where I didn't use the loop counter somewhere in the body. So I don't see this suddenly becoming very popular with ranges.
There was a thread a while ago (or was it this same thread?) that also started with nameless loop variables and ended up with, or made a major detour into, nameless scope guards. I'm not sure what the conclusion was. I think I said it then, and I will repeat again, that I generally concur with your assessment: nameless loop variables are not that useful, while nameless scope guards would be very nice to have; if they can double as nameless loop variables, well, OK. Doing it otherwise, i.e., having nameless loop vars but no nameless scope guards would only be adding baroqueness to the language.