lua-users home
lua-l archive

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



Lua 5.0 refman says:

"The behavior [of the iterative for statement] is undefined if you assign to var_1 inside the block."

As we all know, this means that 'for k,v in pairs() ..blahblah..' you must not (never, ever!) change the 'k' within the loop. For other iterators (s.a. lines()) there may be only one var returned that should not be changed. It's always the first.

The point is:

- Could the Lua interpreter detect the write within it's parsing, and simply refuse to compile such code. I feel this would be very welcome, and smoothening to Lua newbies especially, since otherwise the program just works erroneously without an obvious reason.

What do you say?

-ak