[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua 5 getglobals
- From: "Wim Couwenberg" <w.couwenberg@...>
- Date: Mon, 17 Feb 2003 17:03:36 +0100
Hi,
I encoutered a problem with the getglobals call in Lua 5.
In a particular function I want to retrieve the globals table of the
_calling_ function, so I do a getglobals(2). (I want to "switch" to the
caller's context.) However, sometimes this does _not_ return the callers
globals! After some fiddling I tracked the problem down to Lua's use of
optimized tail calls. Because tail calls reuse a stackframe instead of
creating a new one, a getglobals(n) will effectively skip all tail calls and
end up at a higher level than expected.
Is there a way around this, or is there another (better) way to get the
callers globals table?
Thanks,
Wim