[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: about "eq", "lt" and "le" metamethods
- From: philippe.castagliola@...
- Date: Sun, 23 Nov 2014 16:51:52 +0100 (CET)
Concerning the "eq" metamethod, in the Lua5.3 Reference Manual it is written "The result of the call is always converted to a boolean" and ... I wonder why?
I have the feeling this is an unnecessary constraint. Why not just leave the final decision to the programmer?
For example, if two tables a={1,2,3} and b={1,2,5} share the same metatable with an "eq" metamethod
- the programmer could decide that a==b returns false because the tables do not contain the same values
- BUT he could also decide that a==b returns a table {true,true,false} (like in Matlab like languages) where the comparison is performed element-wise.
Philippe