lua-users home
lua-l archive

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


GrayFace <sergroj@mail.ru> writes:

> On 08.01.2011 14:34, David Kastrup wrote:
>>> Just to get it straight: can it ever make sense to insert nil using
>>> table.insert()?
>>>
>>> 'Should' that not rather throw an error, because any table.insert()
>>> after that could have undefined behavior?
>>>
>>> Isn't it pretty much guaranteed you'd never want to do |table.
>>> insert(t,n,nil)|?
>>
>> I think it should be defined as a straight noop not changing the table
>> at all, ever.
>
> What's the use case?

insert(t,n,somefunction(...))

where somefunction may decide not to return a value.

> IMO, it's good the way it is. Less checks mean more code and
> documentation elegance.

Care to explain?

-- 
David Kastrup