[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Proposal: lua_pushfoo() should return 1
- From: Tim Hill <drtimhill@...>
- Date: Wed, 3 Sep 2014 00:45:51 -0700
On Sep 2, 2014, at 11:45 PM, duz <duz@sol-3.de> wrote:
> On 02.09.2014 13:57, Roberto Ierusalimschy wrote:
>>> [...]
>>> where if lua_pushx would return 1, the then possible source code
>>> return lua_pushx (L, xxx)
>>> often times would be compiled to just:
>>> jump lua_pushx
>>> So there would actually be a small technical benefit.
>
There are two advantages to tail-calls: the first is a small performance improvement which collapses a call/ret into a jump. The much bigger (potential) advantage is that it doesn’t use stack space, and this means that recursive functions that can take advantage of this do not run the risk of stack overflows.
—Tim