Why do parameter values in Lua C functions show up at the bottom of the stack? -
take example simple c function lua:
int luacfunc(lua_state *l) { printf("%g\n", lua_tonumber(l, 1) + lua_tonumber(l, 2)); }
in case, parameters show index 1
, 2
. since positive number represent stack bottom-up, mean parameters located @ bottom of stack, not top.
why case? wouldn't require shifting entire stack on every function call make room parameters?
the lua stack specific function call. each c function call gets own "stack" (it's slice of bigger stack, that's hidden you). arguments both @ top , @ bottom, because they're thing on stack.
Comments
Post a Comment