[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Behavior of lua_resume() in Lua 5.4
- From: Roberto Ierusalimschy <roberto@...>
- Date: Mon, 14 Oct 2019 13:28:21 -0300
> In general, I am wondering what prompted this change to lua_resume()?
It simplifies the implementation. In Lua 5.3, a yield had to "fake"
the bottom of the stack, so that those extra values did not appear
to the caller. That created several small issues (e.g., with the
debug API). This new implementation is more "honest", showing the
stack as it really is.
> Last, but not least: the new lua_resume() doesn't appear to always
> behave as described in the manual. When the coroutine returns (rather
> than yields) the value of *nresults seems to always be equal to
> what lua_gettop() returns. That means it counts not only the values
> returned by the coroutine, but also those that have been at the bottom
> on the stack since before the coroutine was started. I can't imagine
> that to be the intended behavior. It looks very much like a bug to me.
Coroutines are always created on a new empty thread, so there should be
no values "at the bottom on the stack since before the coroutine was
started." I think the old resume behaved exactly the same way.
-- Roberto