[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: a lua_len that give return, not a new value on stack?
- From: Andrew Starks <andrew.starks@...>
- Date: Fri, 22 Nov 2013 12:33:46 -0600
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
- Follow-Ups:
- Re: a lua_len that give return, not a new value on stack?, Dirk Laurie
- Re: a lua_len that give return, not a new value on stack?, Liam Devine
- Re: a lua_len that give return, not a new value on stack?, Lourival Vieira Neto
- Re: a lua_len that give return, not a new value on stack?, Craig Barnes
- Re: a lua_len that give return, not a new value on stack?, Tim Hill