Hey,
Since the generated lua code may contain features that are not present in Lua 5.1, there might be a need for Lua polyfills, namely the table.pack and table.unpack methods (of which neither are available in Lua 5.1).
For example
// zoo() actually returns an array we want to unpack.
// Otherwise we could use /** !TupleReturn */ decorator!
let [foo, bar] = zoo();
Results in
local foo,bar=table.unpack(zoo())
Which won't work in a strict Lua 5.1 environment.
Proposed polyfills
table.pack
if not table.pack then
function table.pack (...)
return {n=select('#',...); ...}
end
end
Source: https://github.com/stevedonovan/Penlight/blob/master/lua/pl/compat.lua#L133
table.unpack
if not table.unpack then
function table.unpack(...)
return unpack(...)
end
end
Hey,
Since the generated lua code may contain features that are not present in Lua 5.1, there might be a need for Lua polyfills, namely the
table.packandtable.unpackmethods (of which neither are available in Lua 5.1).For example
Results in
Which won't work in a strict Lua 5.1 environment.
Proposed polyfills
table.pack
Source: https://github.com/stevedonovan/Penlight/blob/master/lua/pl/compat.lua#L133
table.unpack