lua-users home
lua-l archive

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


It may be helpful to remember in the context of the code aesthetics that Lua enforces almost no restrictions on where statements go. For instance, it is perfectly legal to write this:

do local i = 0 while i < 10 do i = i + 1
   print("Not a for loop!")
   -- loop body statements
end end

if you really want something that "looks like a for loop" with the desired behavior. Of course, the "end end" is a bit ugly.

On Mon, Dec 12, 2022 at 9:02 AM Gé Weijers <ge@weijers.org> wrote:


On Mon, Dec 12, 2022 at 4:47 AM Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
- It is possible that the next Lua version will operate directly with
the loop variable, without any internal copy.

- It is possible that, in the next Lua version, the loop control
variable will be implicit declared as <const> to make the above change
safer.

The second item would be a good idea, for both the numeric and generic for loops. 

--