Jeremy Penner
3d52b70bbc
subrepo: subdir: "vendor/lite" merged: "2783adc" upstream: origin: "https://github.com/jeremypenner/lite.git" branch: "master" commit: "2783adc" git-subrepo: version: "0.4.2" origin: "https://github.com/ingydotnet/git-subrepo" commit: "65fde50"
27 lines
428 B
Lua
27 lines
428 B
Lua
local strict = {}
|
|
strict.defined = {}
|
|
|
|
|
|
-- used to define a global variable
|
|
function global(t)
|
|
for k, v in pairs(t) do
|
|
strict.defined[k] = true
|
|
rawset(_G, k, v)
|
|
end
|
|
end
|
|
|
|
|
|
function strict.__newindex(t, k, v)
|
|
error("cannot set undefined variable: " .. k, 2)
|
|
end
|
|
|
|
|
|
function strict.__index(t, k)
|
|
if not strict.defined[k] then
|
|
error("cannot get undefined variable: " .. k, 2)
|
|
end
|
|
end
|
|
|
|
|
|
setmetatable(_G, strict)
|