dear list,
I have noticed that `table.unpack(list [,i [, j]])` will NOT regards the `n` field in the `list` table,
I know I can write it like this:
``` table.unpack(list, 1, list.n) ```
but will it be a good idea to make it read `n` field in table.unpack?
It certainly is a source if confusion until you notice that not only are pack and unpack *not* the inverse of each other... but that they are not available consistently across Lua implementations. Here's what I always use, from https://github.com/lua-stdlib/normalize :
local pack = table.pack or function (...) return { n = select ("#", ...), ...} end
local table_unpack = table.unpack or unpack local function unpack (t, i, j) return table_unpack (t, tointeger (i) or 1, tointeger (j) or len (t)) end
Why not write a PowerPatch for the lua-wiki that fixes the inconsistency in core too? thanks and happy new year!
Happy New Year! |