[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Definition of table.insert
- From: Alexander Gladysh <agladysh@...>
- Date: Sat, 8 Jan 2011 14:48:04 +0300
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:
>>> GrayFace <sergroj@mail.ru> writes:
>>>> On 08.01.2011 14:34, David Kastrup wrote:
>>>>> I think it should be defined as a straight noop not changing the table
>>>>> at all, ever.
>>> insert(t,n,somefunction(...))
>>> where somefunction may decide not to return a value.
>> You can not be sure what user meant by this. Perhaps he does want to
>> insert nil.
> 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.)
Alexander.