lua-users home
lua-l archive

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


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.