I need to perform operations on Lua tables from C where the tables are treated as lists or queues. Specifically I need to insert an element at the head, and remove the head element, and have the other elements move to accommodate the new element.
This would be simple in straight lua, I'd use
I believe you can reuse the functions
static int tinsert (lua_State *L) static int tremove (lua_State *L)
and the macro
#define aux_getn(L,n) (luaL_checktype(L, n, LUA_TTABLE), luaL_getn(L, n))
which are in the ltablib.c. They depend only on Lua's API.