Comment by pvitz

Comment by pvitz 15 hours ago

0 replies

From the manual:

   The control variable in for loops is read only. If you need to change it, declare a local variable with the same name in the loop body.
Also [0]: Roberto Ierusalimschy > So what's the rationale to make them constant now? Does it have performance > reasons?

Yes. The old code does an implicit "local x = x" for all loops, in case you modify 'x'. With the new semantics, the code only does it when you ask for it.

[0] https://groups.google.com/g/lua-l/c/SlAG5QfpTac