lua-users home
lua-l archive

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


On 11 Sep 2021, at 9.55, Philippe Verdy <verdyp@gmail.com> wrote:
> Isn't the error generated by "type()" superfluous when it is called with no argument at all? Shouldn't it simply return nil so that "type(('A'):byte(2))" will safely also return nil without any error?

Nope. 'type' is a function that expects one argument. How is this any different from, say, math.sin? Would you expect math.sin() to return 'nil' as well?

Generally speaking, it's good that functions expecting one argument raise an erorr when given zero arguments. That helps catching bugs earlier.

Petri