This is only available in the development/preview version and is not yet
in a release of Lua.
A function such as `function example(...args) <body> end` is shorthand
for `function example(...) local args <const> = table.pack(...) <body> end`.
In case this `args` table is only used in the read versions of
`args[expr]` and `
args.name` the table is actually never allocated.
This allows to iterate through the arguments without a table allocation
or requiring to copy all varargs elements when using the `select` method.
For example a sum method which needs to copy all varargs in the uses of
`...` in
function sum(...)
local res = 0
for i=1,select('#', ...) do
res = res + select(i, ...)
end
return res
end
could now be written as
function sum(...args)
local res = 0
for i=1,args.n do
res = res + args[i]
end
return res
end
without a table allocation or all the copies of the varargs done
previously for the `select(i, ...)`.
Regards,
Xmilia