lua-users home
lua-l archive

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

On Wed, Mar 2, 2011 at 10:27 AM, Axel Kittenberger <> wrote:
> It would be cool if we could do:
> for i, v in ... do
> tough, without having to pack ...

And impossible, because the bit following 'in' isn't just a simple
function!  For instance, io.lines() returns a function on Lua 5.1, but
LuaJIT 2.0 returns a function and a file object;  (i)pairs always
returns two items.

However, a simple C extension P could be written that could make 'for
i,v in P(...) do' pretty optimal - it's very efficient to access
multiple arguments in C.

steve d.