lua-users home
lua-l archive

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


> This then gets the index of the _TRACEBACK function on the stack
> > err_func = lua_gettop (L);
>
> Then you call with that index -- presumably if you do anything to
> stack before this call, the err_func will no longer be valid, right?

So long as you don't pop the function off or do an "insert", etc., the value
of err_func will be fine.  This is just normal stack handling (yes the
parameter is the index of the error function on the stack).  Recording the
value into a variable keeps you from having to work out what NEGATIVE value
to use (after all you're going to at least push the function to call, and
its arguments before calling pcall).