[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lua 5.3 changes to .__eq
- From: "Soni L." <fakedme@...>
- Date: Sun, 12 Jul 2015 14:19:09 -0300
On 12/07/15 12:35 PM, Roberto Ierusalimschy wrote:
Why not check both metamethods (if they're different), and `and` their
results? `A.__eq(...) and B.__eq(...)`
The reason the difference matters to me is that someone who writes a random or
otherwise noncommutative method is (definitely) doing it to themselves. But at
least in previous versions of Lua, the language required basic safeguards by
requiring that both operands "share the same metamethod".
I think you can say the same now: someone who writes an A.__eq that
says it is equal to B, when B disagrees about that, "is doint it to
themselves". Your objects should only say they are equal to objects
they know about (but, as Dirk pointed out, may need a different method).
Disclaimer: these emails are public and can be accessed from <TODO: get a non-DHCP IP and put it here>. If you do not agree with this, DO NOT REPLY.