[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: globals
- From: Steve Dekorte <steve@...>
- Date: Mon, 4 Jun 2001 15:29:34 -0700
On Friday, June 1, 2001, at 06:54 PM, Edgar Toernig wrote:
Use this to catch assignments to undefined globals (=nil) instead:
settagmethod(tag(nil), "setglobal", function(n,v) error(...) end)
Ah, thanks.
So would be a reasonable solution to the locals problem?:
settagmethod(tag(nil), "setglobal", function(i, v)
local c = strsub(i, 1)
local t = type(i)
-- perform if function or class assignment
if t == "function" or (c == strupper(c) and t == "table") then
globals()[i] = v
return
end
-- otherwise, raise error
print("no such local variable: '"..i.."'")
end)