lua-users home
lua-l archive

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


I keep arguing with sandbox writers that debug.getmetatable should be allowed in sandboxes, even if limited to be unable to get the metatable of specific objects (from a blacklist table or something probably).

Something that would be really useful in Lua would be callmetamethod(table, "name", args), then I would be able to implement things like

local t = setmetatable({},{__metatable="this table is protected", sort__sortcmp=function() <something> return <comparator function> end})
function sort(t)
local compfunc = callmetamethod(t,"sort__sortcmp") or <default comparator function>
    local sorted = {}
    <sort code>
    return sorted
end
sort(t)

even in extremely sandboxed environments...