[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Exit one Lua state from a (C) API function
- From: Viacheslav Usov <via.usov@...>
- Date: Sun, 28 Feb 2021 15:39:34 +0100
On Sat, Feb 27, 2021 at 6:08 PM bel <firstname.lastname@example.org> 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.