On Mon, Jul 25, 2016 at 12:51 PM, steve donovan
<steve.j.donovan@gmail.com <mailto:steve.j.donovan@gmail.com>> wrote:
I still think that if Lua 5.4 provided a single unique constant null
(without any other properties) then we are fine. Saying 'if v ~= null`
is not much harder than `if v ...` and has the advantage of
explicitness. All packages would then have the same agreed sentinel
value for filling holes.
IMO, discussions about "what should I insert in the holes?" leads to
unnecessary over-complications of the language.
The "holes problem" exists only in the context of sequences,
so introducing "null" type is not a good idea as it affects the whole
language.
If introducing of new sequence-constructor-syntax (and standard
metatable for sequences) is rejected as it seems to be overkill,
then the suggestion with multiple returned values of "table.pack"
satisfies look-and-feel of Lua best of all other suggestions.
local tbl, idx_from, idx_to = table.pack(...)
This way an arbitrary tuple (with holes inside) may be "packed" into a
tuple of three non-nil values (a table and two indices),
that solves the "holes problem" and "pack-unpack symmetry problem" at
the expense of some additional verbosity.