lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> 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