跳转到内容

模組:No globals

被永久保护的模块
维基百科,自由的百科全书

这是本页的一个历史版本,由Great Brightstar留言 | 贡献2014年10月5日 (日) 05:58 (中文化)编辑。这可能和当前版本存在着巨大的差异。

local mt = getmetatable(_G) or {}
function mt.__index (t, k)
	if k ~= 'arg' then
		error('读取该非全域数据出错:' .. tostring(k), 2)
	end
	return nil
end
function mt.__newindex(t, k, v)
	if k ~= 'arg' then
		error('写入该全域数据出错:' .. tostring(k), 2)
	end
	rawset(t, k, v)
end
setmetatable(_G, mt)