[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: incorrect "error" signaled by type(value), when the argument value is nil
- From: Petri Häkkinen <petrih3@...>
- Date: Sat, 11 Sep 2021 11:51:08 +0300
On 11 Sep 2021, at 9.55, Philippe Verdy <firstname.lastname@example.org> 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.