lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



On 15/10/2006, at 9:02 AM, Jérôme VUARAND wrote:

lua_error function is supposed to be called from a protected call, and
all luaL_check* functions call it. Instead you can check the stack
safely with calls to lua_is* and other similar functions. That way you
don't have to add an additionnal pcall layer. Example:

int main()
{
   lua_State* L = luaL_newstate();
   luaL_openlibs(L);
   lua_pushcfunction(L, foo);
   if (lua_pcall(L, 0, 1, 0)==0)

I understand that, and perhaps was in a dream world when I used luaL_checkstring, however in your example there is a possibility, slight perhaps, that lua_pushcfunction will fail due to being out of memory.

Maybe it will happen so infrequently, that we can simply advise the users to "turn the power off and on again" in the 1 time in 10 years that it happens. :)

- Nick