lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Yes, thats obvoius now. But it seems to be a rather unexpected exception
to me. It there any rationale behind this exception?

If loop variables were global by default then only a single loop can be active at any given time, because the loop variables would clash?* Maybe that doesn't sound too bad but consider using two modules (by different authors) in your code which both use a for i = 1, N loop and the two loops overlap without your specific knowledge. That could break either module at any given time though the code of either module would look perfectly fine when you try to find the bug...

 - Peter Odding

* Of course a for i = 1, N loop will always run from 1 to N, irrespective of any other loops in the code, but my point was that any use of the variable "i" could pick up the "i" from either module...