Re: Lua 5.2 and in-do-end
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Lua 5.2 and in-do-end
- From: Richard Hundt <richardhundt@...>
- Date: 2010年1月25日 13:02:33 +0100
David Burgess wrote:
On 25/1/2010 12:28 PM, Mark Hamburg wrote:
function pushenv( newenv )
local oldenv = getfenv( 1 ) -- However one gains access to it...
POUNCE. Methinks that the indoend thing would aided by a currentenv()
function...
here's a hackish version:
function currentenv()
local getlocal = debug.getlocal
local e = nil
local x = 0
while true do
x = x + 1
local n,v = getlocal(2, x)
if not n then break end
if n == "(environment)" then
e = v
end
end
return e
end
-Rich