|
On 11/09/2011 19.33, Florian Weimer wrote:
Sorry, but I don't agree. I know this may be nitpicking, but the sentence you cite refers to an *list of expressions* (emphasis mine):* Lorenzo Donati:Maybe I'm missing something, but IMHO the manual is not clear about it.I just can repeat myself: based on my reading, the no-results case is covered by the manual, in the excerpts as I quoted. It's not a formal document, but the formulation "no adjustment is made" pretty clearly indicates that the no-arguments case is intentionally observable. (It's also visible to the C API, so it's not just select("#"))t.
"If an expression is used as the last (or the only) element of a *list of expressions*, then no adjustment is made (unless the call is enclosed in parentheses)."
In the Lua grammar a list of expressions is defined like this: explist ::= {exp `,`} exp so it cannot be empty and the return statement is defined correctly as: return [explist] that is, explist is optional; thus the statement: return nil has an explist, whereas: returnhas *no explist*, therefore the sentence you cite is not applicable to this latter case (there is no expression list to adjust or not to adjust whatsoever).
The meaning of a "bare" return statement, doesn't appear to be *clearly* defined (or I couldn't find/understand it). Besides the effect detectable by select (which is not part of the language), I cannot find anything that guarantees that
return and return nilhave different semantics. For example, Lua team could well change the implementation between bugfix releases (say 5.1.4 and 5.1.5) and make "return" behave as "return nil" and this won't go against anything written in the manual. "select" will return 1 instead of 0, but this again won't contradict the manual as it is".
Cheers. -- Lorenzo