Question: why is the loop counter assigned?

One thing I think is a bit strange is the notion that the loop counter
is assigned a value after the loop is done. Why is that ?

for example:

for i to 10 do
print(i)
end do;

The above code will simply print 1..10 but then if you simply run:

i;

then 11 will be printed out. How often do you actually need i to be assigned
a value after the loop is done?

I think it would have been much better if i is unassigned when the loop is done
othewise it can create problems for the user later on if he does not realise that
i is already asigned a value.

Please Wait...