lua-users home
lua-l archive

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


On Fri, Feb 25, 2011 at 23:22, Hisham <hisham.hm@gmail.com> 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():

> f=function()end
> assert(f())
stdin:1: bad argument #1 to 'assert' (value expected)
stack traceback:
	[C]: in function 'assert'
	stdin:1: in main chunk
	[C]: ?

Alexander.