阅读背景:

LUA constant

来源:互联网 
function constant(who)
	local smt = function(who)
		local mtt = {
		__index = function(t,k)
			return who[k]
		end,
		__newindex = function(t,k,v)
			if(who[k] == nil) then
			  who[k] = v;
			end
		end
		}
		return mtt;
	end
	local tag = {}
	setmetatable(tag, smt(who))
	return tag	
end

function main()
	local PROTOCOLS = constant({TCP=1,UDP=2,ICMP=3,RAW=4})
	PROTOCOLS.IDP = 9;
	print(PROTOCOLS.TCP);
	PROTOCOLS.TCP = 5;
	print(PROTOCOLS.TCP)
	
	print(PROTOCOLS.IDP)
end

xpcall(main, function(msg)
	
end)
function constant(who)
	local smt = 



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: