Skip to content

Instantly share code, notes, and snippets.

@katlogic
Created August 5, 2016 00:19
Show Gist options
  • Select an option

  • Save katlogic/9c02921f531f49c2b03a4610d891ff11 to your computer and use it in GitHub Desktop.

Select an option

Save katlogic/9c02921f531f49c2b03a4610d891ff11 to your computer and use it in GitHub Desktop.
-- compat
local unpack = table.unpack or unpack
local print = print
local debug = debug
local table = table
local _ENV = setmetatable({}, {__index=function(t,k)
if (k ~= 'arg') then
error("undefined global "..k)
end
local res = {}
local i = -1
while true do
local n, v = debug.getlocal(2, i)
i = i - 1
if not n then return res end
table.insert(res, v)
end
end})
-- 5.1 code follows
function x(...)
print(unpack(arg))
end
x(1,2,3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment