[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Proposal: lua_pushfoo() should return 1
- From: Dirk Zoller <duz@...>
- Date: Tue, 02 Sep 2014 10:15:38 +0200
On 09/02/2014 01:58 AM, Rena wrote:
More accurately, it should return the number of values it pushed,
which for most push functions will always be 1.
That would simplify returning a value slightly:
return lua_pushinteger(L, 42);
instead of:
lua_pushinteger(L, 42);
return 1;
Besides the small simplification for the writer of the code,
this would allow the C-compiler to do tail call optimization.
lua_pushx (L, xxx);
return 1;
compiles to
call lua_pushx
mov 1, register
return
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.