lua-users home
lua-l archive

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


On Wed, Sep 17, 2014 at 9:49 AM, Tim Hill <drtimhill@gmail.com> wrote:
> Quoth polyglot:
>
> 5.2 REFERENCE MANUAL
>
> "Unless a __len metamethod is given, the length of a table t is only defined
> if the table is a sequence, that is, the set of its positive numeric keys is
> equal to {1..n} for some integer n. In that case, n is its length."

I'd say it's at least ambiguous, particularly given that Lua does not
recognize a naked zero as an integer in its string library functions
that return indices, but somewhat paradoxically recognizes -1 as such:
"When indexing a string in Lua, the first character is at position 1
(not at 0, as in C)." Ref. Manual, 6.4.

I realize that -1 is a token in that context but still the superficial
illogic of recognizing a negative value as an integer whilst denying
zero citizenship is kind of fun. ...  :-)

Regards,

Paul

-- 
[Notice not included in the above original message:  The U.S. National
Security Agency neither confirms nor denies that it intercepted this
message.]