On 26/03/07, *Alex Queiroz* <asandroq@gmail.com
<mailto:asandroq@gmail.com>> wrote:
Hallo,
On 3/26/07, Lee Hickey <lahickey@gmail.com
<mailto:lahickey@gmail.com>> wrote:
>
> Is there a standard way to set a 'default' error handler for
lua_pcall,
> rather than the usual method of inserting a c function into the
stack before
> each pcall. I am currently setting up a global error handling
function
> immediately after creating a lua_State, and using this, but this
is prone to
> being obliterated by any C code which doesn't respect the stack
properly.
>
You can create a C function my_pcall() that takes one less
parameter and always push
your customized error handler on the stack.
Cheers,
Thanks. What I forgot to mention is that I want to remove the overhead
of having to insert this extra parameter for every pcall. My game engine
makes many pcalls and I would rather have each of these calls be as
cheap as possible. This need isn't based on any kind of profiling, so I
am guilty of a little blind optimising, but many unnecessary lua_inserts
per frame seems like a sensible thing to avoid if at all possible.
Regards,
Lee.