lua-users home
lua-l archive

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

On Wed, Jan 19, 2011 at 10:29 PM, David Manura <> wrote:
> Two minor points about the grammar in the Lua Reference Manual:

Another trivial point:

    for var_1, ···, var_n in explist do block end
  is equivalent to the code:
       local f, s, var = explist
       while true do
         local var_1, ···, var_n = f(s, var)
         var = var_1    --[*]
         if var == nil then break end   --[*]

In actual implementations, there's no reason to set `var` on break, so
the marked [*] lines are swapped:

         if var_1 == nil then break end
         var = var_1