call_protected still uses the {...}
pattern which has this gotcha. But
it's not exposed in the product, at least.
2KACFSV7BYUNP5L4YP6BGFOCJY26VBOCSC243QG4FCR4X37KCRFQC
-- like map, but support nils inside arr
-- arr must provide its length in an 'n' field,
-- as returned by 'unpack'.
map_nil = function(arr, f)
local result = {}
for i=1,arr.n do
result[i] = f(arr[i])
end
result.n = arr.n
return result
end
-- like table.pack from Lua 5.2
-- https://stackoverflow.com/questions/7183998/in-lua-what-is-the-right-way-to-handle-varargs-which-contains-nil/7186820#7186820
pack = function(...)
local result = {...}
result.n = select('#', ...)
return result
end