lua-users home
lua-l archive

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


Alexander Gladysh <agladysh@gmail.com> writes:

> On Sat, Jan 8, 2011 at 14:55, David Kastrup <dak@gnu.org> wrote:
>> Alexander Gladysh <agladysh@gmail.com> writes:
>>> On Sat, Jan 8, 2011 at 14:40, David Kastrup <dak@gnu.org> wrote:
>>>> Alexander Gladysh <agladysh@gmail.com> writes:
>>>>> On Sat, Jan 8, 2011 at 13:28, David Kastrup <dak@gnu.org> wrote:
>
>>>> There is no way to insert nil in a table.  No matter what the user
>>>> wants.
>
>>> Hmm. Why not?
>
>>> t = { 1, 2, 3, 4, 5 }
>>> print("Before:", unpack(t, 1, 5))
>>> for i = #t, 3, -1 do
>>>   t[i + 1] = t[i]
>>> end
>>> t[3] = nil
>>> print("After:", unpack(t, 1, 6))
>
>>> (Strictly speaking that is not a nil, but a "hole", but that is matter
>>> of terminology.)
>
>> No, it isn't.  If I now do t[4]=nil; t[5]=nil; t[6]=nil I have _not_
>> touched t[3] at all, but clearly the table ends up with length 2.  So
>> there definitely has not been a value at index 3.
>
> I am sorry, but I did not speak about "value". I did speak about nil
> or a hole.

If you differentiate between the two, you clearly consider nil a value.

> I also haven't mentioned length of the table.

Just because you did not think through the consequences of your
statement, it does not mean nobody else can.

-- 
David Kastrup