[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: question about debug.getinfo()
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 11 Jan 2018 09:17:59 -0200
> [...]
>
> Thus, if in a tail call, there is no Lua-style stack entry available for
> the calling function. (See also "Programming in Lua", 4th edition, "6.4
> Proper Tail Calls", page 56.)
>
> The possibility of stack entry reuse means that the second condition
> must be re-interpreted as "previous stack entry is a Lua-style stack
> entry" instead of "called from Lua code".
>
> It can be seen that both conditions, not in a tail call and previous
> stack entry is a Lua-style stack entry, are important to ensure that a
> proper Lua-style stack entry is available for the calling function. And
> in this case, getfuncname() calls funcnamefromcode() which proceeds to
> inspect the available stack entry and code of the caller in an attempt
> to find a suitable name for the called function. [...]
You solved it. In interactive mode, when we write
> essai1()
Lua translates it to
> return essai1();
and then the call becomes a tail call. Putting everything inside a do-end
block avoids this translation, and then the call is a regular one. Other
variants would be:
> essai1();
essai1
> do essai1() end
essai1
> ;essai1()
essai1
-- Roberto