Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decide using lua_call() or lua_pcall()?

Tags:

c

lua

I know the basic difference between lua_call() or lua_pcall(), the later one provides more error details.
Is there any other difference? How to decide which to use?

like image 507
XA. Avatar asked May 22 '13 12:05

XA.


1 Answers

Use lua_pcall when you need to handle potential errors at that point in the code. Otherwise, use lua_call and let the error move up the call chain. No need to get paranoid using lua_pcall everywhere.

lua_call is faster than lua_pcall.

Just make sure there is at least one lua_pcall at the top or your app will panic and exit when finding any Lua errors.

like image 121
lhf Avatar answered Oct 20 '22 21:10

lhf