[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Will operator '==' support fulluserdata and number or nil or false
- From: Dirk Laurie <dirk.laurie@...>
- Date: Sun, 24 Feb 2019 15:01:22 +0200
Op So. 24 Feb. 2019 om 14:50 het 奥斯陆君王 <qtiuto@gmail.com> geskryf:
>
> I just want to compare a number and a fulluserdata, and I know it's
> important to ensure value of different type not equal. But only
> compare number and fulluserdata won't affect anything. Secondly, tt
> doesn't break any rule in current __eq metamethod, because a new
> metamethod will be used. Thirdly, It doesn't affect performance,
> because only number type will be affected and fastmt will make sure
> only one table search will be performed if the userdata doesn't define
> such a metamethod. Fourth, fasttm tag still 3 bit unused. Fifth, If
> you want to make sure the value is number, a type check will be faster
> and safer than an equal call. If comparsion for string and number is
> ok, why can't it be extended.
Comparison for string and number is not ok.
> 1<"1"
stdin:1: attempt to compare number with string
stack traceback:
stdin:1: in main chunk
[C]: in ?