controlling stack overflow

According to the lua manual this is how you control stack overflow:

int lua_checkstack (lua_State *L, int extra);

But when I go to try to use this I get this error that asks for an equal sign.
It does this even if I use it this way:

int lua_checkstack (lua_State *L, int extra)

What am I doing wrong.

Also I’ve already been using

setinstructionlimit(0)

but that does not stop the overflow.

My question is, is

int lua_checkstack (lua_State *L, int extra);

depreciated? If so why and how do we implement this particular function? (which is supposed to grow the overall stack size so it does not overflow)

This is supposed to be built on Lua, right? So why should the lua_checkstack function not be available?

I can’t answer why Codea doesn’t include this function, but ideally you don’t want to overflow the stack at all. Perhaps if you share the code that is overflowing, we can help.

That’s an internal C function, not a lua function.

@Andrew_Stacey really? But its called lua_checkstack and its in the lua 5.1 reference manual.

Is there any other way we can grow the stack size then?

I think codea adjusts automatically the stack size until you take too much space (all available memory). This happens to me when i have a bug (infinite loop) so, maybe, you should rather concentrate on what makes your stack overflow: is it a bug? And if not, you can probably rewrite your program to avoid this overflow (usually this is possible with little effort). Remember the ipad is not a desktop PC and has much less memory and power…

@werttoli The section in which it occurs is called “The Application Program Interface” and begins with the line:

This section describes the C API for Lua, that is, the set of C functions available to the host program to communicate with Lua.

Lua is often an embedded language. This section is for communication between lua and the program it is embedded in. So this is probably used internally in Codea but is not exposed to the user.

If your stack is growing out of control, you should figure out why and do something to remedy that at the code level if possible.

Also don’t forget Lua is written in C and in it’s normal use case (adding scripting support to applications written in C) you would interface your C code with your Lua code by use of this (and several other C lua_ functions).

You might be able to call this from within an exported XCode project but as @Jmv38 say’s chances are it’s more likely an issue with the way you’re implementing your code - normally stack overflow occurs because of recursion that goes on too long.

(D’oh - Ninja’d by @Andrew_Stacey :slight_smile: )