lua-users home
lua-l archive

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


On Sat, Feb 27, 2021 at 6:08 PM bel <bel2125@gmail.com> wrote:

> A Lua library function calling lua_pcall cannot be sure the lua_pcall function will return, since the Lua code could also switch to another coroutine.

The manual: "Lua raises an error whenever it tries to yield across an
API call, except for three functions: lua_yieldk, lua_callk, and
lua_pcallk" (beginning of section 4.5).

The whole point of lua_pcall() is that it always returns, except when
it executes, directly or indirectly, some misbehaving "C" code.

'Misbehaving' above is from Lua's perspective as officially
documented. You are entirely free to redefine that in your own
application, you just need to make sure that all the "C" code it uses
is compatible with your definition.

Cheers,
V.