Just use LuaJIT which can handle zero based indexing too.
back
1 comments
ipairs() will not iterate over 0th element though and # will return one less. If that is not an issue, Lua can "handle" it as well.
That is, if I didn't miss a flag in luaconf.h which solves that.
You can trivially write your own iterator that starts at 0, and still uses ipairs's (native) iterator internally:
function ipairs0(arr)
return ipairs(arr), arr, -1
endpairs() iterates over all elements. I never use ipairs() but plain numeric for loops. This works well with #. I only use pairs() in exceptional situations when I have to copy a table with unknown contents.