lua-users home
lua-l archive

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


> My argument was:
> (a) I see this as a useful generic language feature, that while lightweight is also light to implement and understand.
> (b) It cleans up one of the side-cases of Lua, the odd behavior of Lua arrays when faced with nil values.

Maybe I am missing something obvious, but Lua already has an "empty"
value. It is called "false". Of course, it is not a perfect solution,
because now your array cannot have "false" values, as they denote
holes. So, ok, we create a new "empty" value to denote holes. But,,,
wait! As Dirk asked repeteadly without an answer, what if we want to
store an "empty" value into an array? After all, "empty" is a valid value
in the language, is it not? Functions can return "empty" (e.g., rawget),
and therefore I may want to store it in an array (e.g., all the results
of a function, or the results of an array of functions).

The solution seems obvious again: we create a new value, "undefined". But,
wait!...

-- Roberto