[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_yieldk/lua_resume not removing yielded values
- From: Roberto Ierusalimschy <roberto@...>
- Date: Fri, 15 Feb 2013 10:34:55 -0200
> > [...] In other words it seems the nargs of a second lua_resume
> > seems to be ignored, and all values on the thread stack at the moment
> > of the resume are passed to the continuation function.
> This is a documentation problem. When a coroutine resumes after the
> first time, the stack cannot contain anything besides the arguments to
> resume. 'nargs' is mostly ignored (except for error handling and API
The documentation is not that wrong, after all. It says:
To resume a coroutine, you put on its stack only the values to be
passed as results from yield, and then call lua_resume.
Note the "only". It is not very clear about removing the old results,
but it is very clear about not pushing extra elements.