Module:Arguments: Difference between revisions
add a more detailed comment about metatable behaviour
m>Mr. Stradivarius (return a table rather than a function, improve the comments) |
m>Mr. Stradivarius (add a more detailed comment about metatable behaviour) |
||
Line 66: | Line 66: | ||
end | end | ||
-- Define metatable behaviour. | --[[ | ||
-- Define metatable behaviour. Arguments are stored in the metaArgs table, and are only fetched from the | |||
-- fargs and pargs tables once. Also, we keep a record in the metatable of when pairs and ipairs have | |||
-- been called, so we do not run pairs and ipairs on fargs and pargs more than once. We also do not run | |||
-- ipairs on fargs and pargs if pairs has already been run, as all the arguments will already have been | |||
-- copied over. | |||
--]] | |||
metatable.__index = function (t, key) | metatable.__index = function (t, key) | ||
local val = metaArgs[key] | local val = metaArgs[key] |