[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Better custom metamethod/metafield support
- From: "Thiago L." <fakedme@...>
- Date: Sun, 06 Apr 2014 22:35:33 -0300
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...