lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


If you want to be strict, use code like this:

function check(t,...)
        local a=table.pack(...)
        assert(#t==a.n, #t.." arguments expected")
        for i=1,a.n do
                assert(t[i]==a[i],"arg #"..i.." expected to be "..t[i])
        end
end

local function strict(f,t)
        return function (...)
                check(t,...)
                return f(...)
        end
end

require=strict(require,{ "string"})

require(23)
require("a","oops")