lua-users home
lua-l archive

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


on 4/9/08 5:47 AM, Mike Pall at mikelu-0804@mike.de wrote:

> And apairs() could replace the 'for i,x in pairs{a,b,c} do' idiom,
> too. apairs() creates a closure, which is more lightweight than
> creating a table plus its array part.

Though if we're worrying about optimization, it would be nice to recognize
that if given something like:

    for i, x in ipairs{ "a", "b", "c" } do
        --
    end

Then the constructed table can be lifted out as a constant.

Of course, that assumes that one knows what ipairs does and that it doesn't
modify the table in some way which of course we don't know...

Mark