lua-users home
lua-l archive

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


On Wed, Jul 18, 2012 at 11:55 PM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> What I find surprising is that even though Lua functions implemented
>> without vararg convert missing arguments to nil, the core functions
>> with a finite number of arguments don't. I'd expect them to do the
>> same.
>
> C functions are always varagrs and so are allowed to do whatever they
> seem fit with respect to arguments.
Yes, I know that...

> For the functions in the standard
> Lua library, it's a question of what we deem to be more useful to the
> Lua programmer who is going to use them. Do you really want to write
> tostring() without arguments? What for?

It is more as a failsafe for this kind of scenario:

    table.concat{stuff, tostring(foo()), ... }

where foo is dynamic and may return nothing.

> Do you really want to write rawset(t,k) to save you from typing rawset(t,k,nil)?

    Same as above...

--py