Take for example a simple C function for lua:
int luacfunc(lua_State *L)
{
printf("%g\n", lua_tonumber(L, 1) + lua_tonumber(L, 2));
}
In this case, the parameters show up as index 1
and 2
. Since positive number represent the stack bottom-up, it would mean that the parameters are located at the bottom of the stack, not the top.
Why is that the case? Wouldn't it require shifting the entire stack on every function call to make room for the parameters?