[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: "import"?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Sun, 01 Oct 2000 12:15:18 -0200
Maybe something like
local newenv = {}
local oldenv = globals()
local oldtm = gettagmethod(tag(nil), 'getglobal)
settagmethod(tag(nil), 'getglobal', function (varname)
return %oldenv[varname]
end) -- alow new environment to use all variables from old one
globals(newenv) -- set new environment
dofile(filename)
globals(oldenv) -- restore environment
settagmethod(tag(nil), 'getglobal', oldtm)
return newenv
-- Roberto