[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Numeric for loop: Changing control variable REALLY dangerous?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 12 Dec 2022 09:10:45 -0300
In Lua 5.1, 5.2, and 5.3, the reference manual included pseudocode
trying to explain the semantics of for loops:
https://www.lua.org/manual/5.1/manual.html#2.4.5
https://www.lua.org/manual/5.2/manual.html#3.3.5
https://www.lua.org/manual/5.3/manual.html#3.3.5
As you can see, changing the declared loop control variable v does not
affect the actual control variable var, which is an ordinary local
variable that is hidden. Check out also the bytecode listing for say
`for i=1,10 do print(i) end`.