lua-users home
lua-l archive

Re: minor lua refman grammar points

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


On Wed, Jan 19, 2011 at 10:29 PM, David Manura <dm.lua@math2.org> wrote:
> Two minor points about the grammar in the Lua Reference Manual:
Another trivial point:
 -- http://www.lua.org/manual/5.1/manual.html#2.4.5
 for var_1, ···, var_n in explist do block end
 is equivalent to the code:
 do
 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 --[*]
 block
 end
 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

AltStyle によって変換されたページ (->オリジナル) /