Module:Wd: Difference between revisions

Content deleted Content added
Previous edits: Fixed named parameters when calling main
Minor optimisation
Line 1,640:
args = {}
-- copy arguments from immutable to mutable table
-- positional parameters;
-- shift them one index forward
for i, v in ipairs(frame.args) do
if i > 1 then
args[i-1] = v
end
end
-- named parameters;
-- simply copy these
for i, v in pairs(frame.args) do
args[i-1] = v
-- pairs() also iterates over the positional parameters,
-- so ignore those since they have been added by the last loop already
if not args[i] then
args[i] = v
end
end
-- remove the function name from the list
-- last loop added the last positional parameter under its previous key again,
table.remove(args, 1)
-- so just remove it (it has been copied to args[#frame.args-1] already)
table.remove(args)
return p["_"..f](args)