[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Question about Lua/C API lua_error usage
- From: Каплун Сергей <sergeykaplun1998@...>
- Date: Thu, 12 Aug 2021 16:54:37 +0300
Hi, Roberto!
On 12.08.21, Roberto Ierusalimschy wrote:
> > | static int throw_error_at_old_thread(lua_State *cur_L)
> > | {
> > | lua_error(old_L);
> >
> > The Lua Reference Manual (5.4) declares that:
> >
> > | As a general rule, when a C function is called by Lua with a Lua state,
> > | it can do whatever it wants on that Lua state, as it should be already
> > | protected. However, when C code operates on *other* Lua states (e.g., a
> > | Lua-state argument to the function, a Lua state stored in the registry,
> > | or the result of lua_newthread), it should use them only in API calls
> > | that cannot raise errors.
> >
> > In my opinion, "other" means "not protected", but Mike Pall says, that
> > it means "not currently executed" [2].
>
> That sentence starts mentioning "a Lua state", the one the function was
> called with; that is "curr_L" in your example. "Other Lua states" mean
> any Lua state which is not "curr_L".
Thanks for clarification!
It would be nice to mention this explicitly in Lua 5.1 Reference Manual.
>
> -- Roberto
--
Best regards,
Sergey Kaplun