Random variable declaration is a bad idea, very sloppy code however, I do like the idea of
the FOR LOOP control being able to do this because of this simple fact. The loop variable is documented
as undefined out side the FOR LOOP
IIRC, with the exception when the loop was exited by "break" or the like, in which case it is defined? (need to double check)
Beside search the many discussions on this forum, where there are plenty of reasons why even the for loop var would not be a good idea. (And yes, I did read the arguments that were brought in favour, and none prevailed)
And lastly, if the only concern is, not to accidentally use the var after the loop:
- the compiler should emit a "undefined warning" => if not that would be something that you should request. If it does, -we promote warnings to errors.
- and if that is not good enough, and you really think it needs changed syntax / extra features (I don't, but I humour the idea): in the var block on top "var a: TEnumerable loopcounter;" limit it to be used as loop counter, and only avail in loops in which it is a counter. I don't think that is needed, but it is far less problematic, and solves the problem.