[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Operator precedence and unary minus
- From: Tim Hill <drtimhill@...>
- Date: Mon, 21 May 2018 16:15:06 -0700
> On May 21, 2018, at 4:02 PM, Sean Conner <sean@conman.org> wrote:
>
> It was thus said that the Great Tim Hill once stated:
>>
>> You also need to be careful with literals and metatables. Consider:
>>
>> -a * b
>> -10 * b
>>
>> The same result? But what if b has a __mul metamethod?
>>
>> —Tim
>
> -10 * b and b has a __mul metamethod equals -Tim?
>
> -spc (Tongue firmly planted in cheek)
>
Yes yes but you get my point, even with tongue in cheek. In the first case, the return value of the metamethod is negated (according to the proposal), in the second it is not. Something NOT apparent from a casual glance at the code, and quite horrible imho.
—Tim