[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Surprising behavior of table.insert()
- From: Alexander Gladysh <agladysh@...>
- Date: Fri, 25 Feb 2011 23:27:34 +0300
On Fri, Feb 25, 2011 at 23:22, Hisham <firstname.lastname@example.org> wrote:
> I understand the mechanics of this behavior (one pushes nil to the
> stack as opposed to pushing nothing, as can be demonstrated with
> select()), but I wonder if this extra check in table.insert doesn't go
> somewhat against the general behavior of parameter-passing in Lua
> (where missing arguments are filled with nil), given that nil is a
> valid value for the argument in this function.
Sadly, this is common behaviour in Lua API. AFAIR, it was discussed
before, and Lua team opinion is that it is intentional and correct.
It is most annoying in assert():
stdin:1: bad argument #1 to 'assert' (value expected)
[C]: in function 'assert'
stdin:1: in main chunk