lua-users home
lua-l archive

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


Correcting a couple mistakes:

A for statement like

     for var_1, ···, var_n in explist do block end

is equivalent to the code:

     do
       local f, s, var = explist

       --proposed addition
       if type(f)~= "function" and not metatable(f).__call then
         local meta_f = metatable(f).__iter
         if not meta_f and type(f)=="table" then meta_f = pairs end
         if meta_f then f, s, var = meta_f(explist) end
       end

       while true do
         local var_1, ···, var_n = f(s, var)
         var = var_1
         if var == nil then break end
         block
       end
     end