Re: Definition of table.insert
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Definition of table.insert
- From: Henning Diedrich <hd2010@...>
- Date: 2011年1月08日 08:21:05 +0100
Hi Dirk,
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)|?
Or is the rationale that you could fill that hole the next second
and duly have a strict array again?
I tried writing a test loop with inserts and removes on associative
arrays and could not come up with a prediction for insert (I
understood, that's not defined). Insert replaces values in
associative arrays sometimes, instead of moving values up as far as
I can see. I can accept it just should not be used.
But why would insert be allowed to make the table invalid 'for
itself' and put it in such a state. After all, it's not allowed to
accept a string either. So why a nil? That's not a rhethoric
question, I am wondering and if I have overlooked the decisive
message in the list, let me know,
thanks,
Henning