|
|
||
|
On 5-Oct-05, at 4:38 AM, David Given wrote:
As another data point:
C++ (and now C99) allows you to declare loop variables inside loop statements:
for (int i=0; i<10; i++) { printf("%d\n", i); }
It's interesting to note that old versions of the standard decreed that the
scope of the loop variable extended until the end of the enclosing scope;
that is, it was equivalent to:
int i; for (i=0; i<10; i++) ...
However, the standard then changed so that the scope was limited to the for()
block only.
Here are some of the reasons, in no particular order: