|
On Oct 2, 2013, at 1:21 PM, liam mail <liam.list@googlemail.com> wrote:
This isn't about non-integer keys, I perfectly understand (and use) hybrid tables that have both an array and additional information in name/value pairs. It's about arrays that, for a users perspective, have "holes". Lua doesn't allow this, and it's behavior in such circumstances is counter-intuitive (witness the frequency of posts about the # operator). And *because* users get confused about this, I wish to be very defensive when it comes to writing APIs that *do* expect a well-formed sequence (with or without auxiliary non-integer keys). Before just blindly generating a (possibly erroneous) result, I want to validate the sequence, which in effect means looking for holes (or, more correctly, answering the question: "Does a table with N positive integer keys have all such keys in the range 1..N" which is in line with the strict Lua definition of a sequence). And Lua does not provide an efficient means to do this. That was the point of my post. --Tim |