> when it was added to C++, i "felt" that the scope
> of 'i' wasn't natural; it goes beyond 'for's closure.
> i like a behavior like this:
> 
>       { int i; for (i = 0, ...) ...; }

when i first started to use Limbo, which has a similar looking
idiom, i thought the same.

        for(i := 0; i < 10; i++) {
        }

but actually, having the variable
available outside the scope is so often useful,
e.g.
        for(i := 0; i < end; i++)
                if(sometest())
                        break;
        if(i == end)
                fall_through_condition();

that i now think the non-scoping behaviour is the right thing.

i'm not sure that it's worth adding to plan 9 C though.

Reply via email to