lua-users home
lua-l archive

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


I've looked around for this and can't find it. It's not a big deal,
but I find myself wanting to do

t[#t + 1] = v

and in C, that's actually a lot of code. Right now, I'm inlining a
function like this:
int luaL_returnlen(L, index) {
  lua_len(L, index);
  len = lua_tointeger(L,-1);
  lua_pop(L, 1);
  return len;
}

so that I can inline a function like this:

void luaL_rawsetnexti(L, index){
  lua_rawseti(L, index,luaL_returnlen(L, index) + 1);
}

-------

So, this works. My question:

Is there a better way with the way the C API? Or is the answer, "Welcome to C!"

-Andrew