[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (rc4) now available
- From: Patrick Donnelly <batrick@...>
- Date: Sun, 11 Jan 2015 07:51:02 -0500
On Tue, Jan 6, 2015 at 7:37 AM, Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
> Lua 5.3.0 (rc4) is now available for testing at
> http://www.lua.org/work/lua-5.3.0-rc4.tar.gz
> [...]
> All feedback welcome. Thanks.
4 reference manual comments:
1) For lua_resume, I found this puzzling (not specific to Lua 5.3),
emphasis added:
"To resume a coroutine, **you remove any results from the last
lua_yield**, put on its stack only the values to be passed as results
from yield, and then call lua_resume."
This seems to be a case of the reference manual fitting to the unusual
behavior of the code. In my own tests, nargs is "ignored" and
everything on the stack of L is used as arguments. For the case where
L is yielded, L's stack includes all yielded values. This necessitates
the caller of lua_resume to remove yielded values prior to pushing
arguments. I find this behavior strangely incongruous with the rest of
the API. For example, extraneous items on the stack are thrown out on
return from a C function. I would expect lua_resume to discard values
below nargs on L's stack.
I believe fixing this problem in the manual and in Lua would not cause
issues with existing correct code. [Because existing correct code is
doing the analogous: "pop everything but return values from the C
stack prior to returning". Harmless but vexing to the experienced.]
2) In the reference manual, lua_yield/lua_yieldk pop nresults off the
stack. So, similar to lua_pcallk, the [-?, +?, e] should be
[-nresults, +?, e]. However, in light of (1), lua_yield does not pop
anything off the stack. The caller of lua_resume is "contractually"
expected to do this work...
3) There should be an explanation for the lua_resume "from" parameter.
4) The lua_resume "from" parameter introduces ambiguity when talking
about "push onto the thread stack".
--
Patrick Donnelly