When you interact with Lua API,
you are responsible for ensuring consistency.
you are responsible for controlling stack overflow.
You can use the function
to grow the stack size.
Whenever Lua calls C,
it ensures that at least
LUA_MINSTACK stack positions are available.
LUA_MINSTACK is defined as 20,
so that usually you do not have to worry about stack space
unless your code has loops pushing elements onto the stack.
Most query functions accept as indices any value inside the
available stack space, that is, indices up to the maximum stack size
you have set through
Such indices are called acceptable indices.
More formally, we define an acceptable index
(index < 0 && abs(index) <= top) ||
(index > 0 && index <= stackspace)
Note that 0 is never an acceptable index.