lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> > [...] 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
> checks).

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.

-- Roberto