示例工程 28-release-and-compat
28-release-and-compat/01-compat-shims/main.lua
-- @runtimes lua54 luajit
--- 演示:用 shim 抹平 table.unpack/unpack 差异。
local M = {}
local unpack_values = table.unpack or unpack
--- @return table { values = table, count = integer }
function M.run(log)
log = log or print
local values = { unpack_values({ 1, 2, 3 }) }
log(("count=%d first=%d"):format(#values, values[1]))
return { values = values, count = #values }
end
if not ... then
M.run()
end
return M