|
Boost : |
From: Darren Cook (darren_at_[hidden])
Date: 2005-05-10 17:21:17
> But users might reasonably expect this:
>
> int i = 0;
> for( i : vect )
> {
> }
> // maybe use i here
My feeling is the above should be a compiler warning, that the "i" in
the for loop is hiding the outer "i".
> to use the pre-declared i as a loop variable instead of introducing a
> new variable. That's an important use case, and some allowance should be
> made for it in the chosen syntax.
Wouldn't someone wanting to do something "clever" like that fall back to
using a normal for() or while() loop? I thought for(i:vect){} is a
convenience function to save typing and make code clearer; can it do
something a while() loop cannot?
Darren
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk