跳转到内容

Module:No globals

勤求古训,博采众方
鹿野耕云留言 | 贡献2025年11月26日 (三) 13:05的版本 (创建页面,内容为“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)”)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
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)