lua-users home
lua-l archive

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



On Sep 18, 2014, at 9:33 AM, Steven Degutis <sbdegutis@gmail.com> wrote:

Quoth Tim Hill:

No, I think the OP is correct insofar as what the reference manual says. My
reading of the strict definition of sequence is that an empty table is NOT a
sequence, and therefore the result of # is indeed undefined, regardless of
what it actually returns in practice.

My arguments:

1. The definition does not say that n must be >= 1, only that it must
be an integer; so we rely on whether 0 is a valid length, which we
hold as self-evident.

2. The concept of length precludes the possibility of a negative
length, excluding all negative values of n.

Thus no clarification in the manual is required, so long as these
principles are considered. Therefore I believe the current wording of
this manual quotation is satisfactory.


Well, first off the current wording HAS been revised in the 5.3 alpha ref manual to say “… non-negative integer n” (my italics). And as I have already stated, the fact that a number of people have raised this question does point toward some confusion. Not all software developers, particularly those that only dabble in script languages, may be versed in the subtleties of what the set {1..0} means.

For my mind I would like to see (in ref manual 3.4.7):

“In that case, n is its length.”

Changed to:

“In that case, n is its length (and will thus be zero for an empty sequence)."

Which seems to me to clarify the situation.

—Tim