Reputation: 51
When using the Lua 5.2 API, the code below prints "nil"
function __debug(szName, ...)
print(type(arg));
end
__debug("s", 1, 2, 3, 4);
But this code does work when using Lua 5.1, and prints "table"
Upvotes: 4
Views: 2586
Reputation: 16753
If you are referring to vararg function, the arg
table was deprecated already in Lua 5.1. In Lua 5.2, you can use table.pack
to create arg
if you need it:
function debug(name, ...)
local arg = table.pack(...)
print(name)
for i=1,arg.n do
print(i, arg[i])
end
end
Upvotes: 11
Reputation: 9549
That's because arg
has been deprecated since Lua 5.1. It only remained as a compatibility feature.
References: Lua 5.1 manual, unofficial LuaFaq
a workaround is using this line to generate a table called arg:
local arg={...}
Upvotes: 3