c - 如何决定使用 lua_call() 还是 lua_pcall()?

标签 c lua

我知道 lua_call()lua_pcall() 之间的基本区别,后者提供了更多错误详细信息。
还有其他区别吗?如何决定使用哪个?

最佳答案

当您需要处理代码中那个点的潜在错误时,使用lua_pcall。否则,使用 lua_call 并让错误向上移动调用链。无需在任何地方使用 lua_pcall 变得偏执。

lua_calllua_pcall 快。

只需确保顶部至少有一个 lua_pcall,否则您的应用会在发现任何 Lua 错误时崩溃并退出。

关于c - 如何决定使用 lua_call() 还是 lua_pcall()?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16691486/

相关文章:

在 C 中转换数字类型

c - 使用 `ar -rc` 与 libtool 有什么区别?

c - 发布大页面的正确方法?

c# - ContinueWith 作为 await 运算符的替代

lua - Redis Capped Sorted Set、List 还是 Queue?

c - 在 Windows 上理解 Lua 的 os.tmpname()

c - _BitScanForward64 在 Windows 上使用 MinGW

c - tcsendbreak() 中的持续时间单位是什么?

c - lua c api : how to push a string with a null character in the middle?

Lua-每次分配局部变量时都需要local吗?