Tim Prince
4/11/2011 1:08:00 PM
On 4/11/2011 4:31 AM, Malcolm McLean wrote:
> On Apr 11, 5:49 am, Keith Thompson<ks...@mib.org> wrote:
>>
>> Out of curiosity, what led you to think that i is still visible
>> after the end of the loop?
>>
> C allows this
>
> for(i=0;i<N;i++)
> if(somecondition(i))
> break;
> if(i == N)
> goto condition_not_triggered;
>
> however a lot of programming languages won't allow a similar
> construct, because their counting variables are only visible within
> the scope of the for loop.
>
> This can lead to a certain amount of confusion.
>
Particularly in the style used by a customer of mine, where this
counting variable shadowed one in the outer scope.
We broke company over their refusal to change dependencies on
sizeof(size_t) == sizeof(int).
--
Tim Prince