lua-users home
lua-l archive

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


Leo Razoumov wrote:

NOTE: the definition above never explicitly addresses the issue of
arrays with holes.
Is a hole an element with nil as a value (nil is nither string nor number)??
See below.

     If it has holes it is *not* an array. This is the tricky part.

NOTE: the manual explicitly says that nil cannot be a value in an
array or table (nil also cannot be a valid key).
Direct interpretation of the paragraph above: "t[2]=nil means that
array t does not contain an element t[2]"
It is different from "t[2] exists and has a value of nil".


(3) another discussion of arrays with holes

"For a regular array, with non-nil values from 1 to a given n, its
length is exactly that n,
the index of its last value. If the array has "holes" (that is, nil
values between other non-nil values),
then #t may be any of the indices that directly precedes a nil value
(that is, it may consider any such nil value as the end of the array)."

NOTE: according to (3) arrays can have elements with nil as a value,
contradiction with (2) "the value of a table field can be of any type
(except nil)."

     Wrong. You should read "nil values" here as "absence of values".