lua-users home
lua-l archive

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



On Aug 15, 2014, at 4:45 AM, Jan Behrens <jbe-lua-l@public-software-group.org> wrote:

In normal programming, it might not be a big issue to create tables or
closures. I love to create them :-)  Especially in Lua!  But I wouldn't
like ipairs(...) to always create a closure or table when working on
tables or userdata values with an __ipairs metamethod.

But are you so certain this is a real problem? Is table create such an evil in this case? I would expect that in most real-world cases the table create overhead would be small compares to the time for the entire iteration. And your from/to example doesn’t need a table anyway if you are using numeric indices, since the only value you need to keep is the “to” value.

—Tim