Jump to content

Module:Sandbox/Wnt

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Wnt (talk | contribs) at 00:30, 13 June 2014 (There's not that much room to reorder things. But it's possible to have _everything_ from p after a dotted line to keep it out of the way of the module proper.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
-- The entire meat of the module can be up front with fields of some table that isn't p.
local q = {}

function q.main (action, args)
	return "action = " .. (action or 'NIL') .. "args[1] = " .. (args[1] or 'NIL')
end

-- this final act returns p with the available functions set.  The setmetatable has to be after q is created and q.main defined
local p = {} -- this empty table with metatable serves to convert the first #invoke field to an effective parameter
setmetatable(p, { __index = function(t, k)
	return function(frame)
	    return q.main (k, frame.args)
	end
end })
return p