I see, it is reasoned. If we strictly follow the logic, the length operator should ideally return nil in theese cases, because "it usually represents the absence of a useful value".
This has been debated here many many times. The trouble is that any algorithm that can detect that a table is NOT a sequence is significantly more expensive that the current # algorithm. The Lua teams position is that in the majority of cases you would know if a table was a sequence or not and hence the extra checking would be a (significant) waste of time.
—Tim
|