[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: debug.getlocal losing information
- From: Roberto Ierusalimschy <roberto@...>
- Date: Sat, 3 Jul 2010 09:06:24 -0300
> After some further investigation, I narrowed down the exact problem:
> Using tail calls, the calling function's environment is unavailable.
> [...]
> If part4() calls debug.getlocal(), it returns no information for level
> 4 (what should be the environment of part2).
> part1() avoids this problem by not performing a tail call, but is
> there any better way to access that environment, or is it lost
> forever?
The information is lost forever; that is the whole point of tail calls.
> And then why does the tail call leave an "empty" level instead of
> nothing at all?
This "empty level" is only a counter; there is nothing left. This was
an attempt to hide some tail-call complexities from users, but it seems
to create more confusion. Lua 5.2 does not have these empty levels
anymore, only a bit telling that from level X to level X+1 there has
been removed frames.
-- Roberto