[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: new "empty" value/type in Lua?
- From: Coda Highland <chighland@...>
- Date: Mon, 1 Jul 2013 11:10:32 -0700
On Mon, Jul 1, 2013 at 11:04 AM, Roberto Ierusalimschy
>> Couldn't a lot of ambiguity and unexpected behavior avoided by keeping
>> nil but introducing two new functions to the table library called
>> "table.has(t,key)" and "table.delete(t,key,[to])" - and dropping the
>> deletion via assigning nil?
> At last something new and worth a discussion. Does anyone see problems/
> incompatibilities/etc. with this?
> (But what is "[to]"?)
> Keep in mind that #t would still be undefined for arrays with holes,
> but holes would be much less frequent...
> -- Roberto
The only incompatibility I can see is that "t[#t] = nil" no longer
works as a "pop" operation for a stack-like array; you'd have to use
"table.delete(t, #t)" instead.
Also, I think "[to]" there is for a range delete, like
"table.delete(t, 3, 5)" removes elements 3, 4, and 5.