[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: a lua_len that give return, not a new value on stack?
- From: Andrew Starks <andrew.starks@...>
- Date: Fri, 22 Nov 2013 16:50:51 -0600
On Fri, Nov 22, 2013 at 4:20 PM, Tim Hill <drtimhill@gmail.com> wrote:
> Is there some reason you are doing rawset? Also, what about keeping everything in the stack and using lua_arith() to do the add? So all you would need to do is:
>
> lua_len(…)
> lua_pushinteger(…, 1);
> lua_arith(LUA_OPADD);
> lua_settable(…)
>
> Which does the whole thing in 4 lines.
this looks good but the prior discussion revealed a good way. Turns
out, I'm making the table in C, so I know that there is no metamethod.
`#define nml_rawsetnexti(L, index) lua_rawseti(L, index, lua_rawlen(L,
index) + 1)`
is what I went with.