lua-users home
lua-l archive

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



> 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