lua-users home
lua-l archive

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


2014-08-16 15:37 GMT+02:00 Andrew Starks <andrew.starks@trms.com>:

> The ability to directly overload the standard iterator that returns numeric
> keys in order will be missed, but only a little. It's only a little odd to
> ask a user to use pairs in that case and I can always write a custom
> iterator.

I'm already at the point where I always use next,tbl and never
pairs(tbl). It will be only a small step from there to always using
inext,tbl and never ipairs,tbl:

function inext(tbl,k)
   k=(k or 0)+1
   local v=tbl[k]
   if v then return k,v end
end

It would be nice if standard Lua offered this inext built-in, but the
beauty of Lua is that all of the standard library is easily customizable.