lua-users home
lua-l archive

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

[Apologies I accidentally hit send on the previous reply.]

On Fri, Feb 15, 2013 at 7:34 AM, Roberto Ierusalimschy
<> wrote:
>> > [...] 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.

It would seem to me that this is inconsistent with the rest of the
API. After all, you don't have to clear the stack of other items
before calling lua_call. It would seem removing extraneous items on
the stack on resume is the sensible and expected behavior.

The documentation could be clearer regardless.

- Patrick Donnelly