[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: omission in lua_yield docs
- From: John Belmonte <john@...>
- Date: Sun, 27 May 2012 16:15:05 -0400
On Sun, May 27, 2012 at 3:29 PM, Roberto Ierusalimschy
> The docs states this:
> This function should only be called as the return expression of a C
> function, as follows:
> return lua_yieldk (L, n, i, k);
State that it does.
> Therefore, its return value (or whether it returns at all) is irrelevant;
> your code will never see it.
The "therefore" part, which is not in the docs, is only obvious to
someone understanding coroutines, and understanding that Lua C
functions typically return an int for number of arguments, and that
yield is an int rather than void function to support the idiom cited
and avoid compiler nagging about return value.
My oversight isn't defensible-- it was late at night, and I haven't
touched coroutines or the C API for several years. I'm only pointing
out that all of this might not be obvious to an unsuspecting person
landing on the lua_yield documentation. He'll wonder "why isn't the
return value defined"?