lua-users home
lua-l archive

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

On Tue, Mar 29, 2011 at 11:27:12PM +0200, Guilherme Destefani wrote:
> I understand that the identity comparison is making the whole
> operation more optimized in the common case, but I'm not sure that
> assume everything always compare itself to true is the right
> thing to do.

Well, if you deny the logical validity of A==A, then Aristotle
lived in vain.  

What your argument does show, however, is that there is a need for 
a __ne metamethod.  It should not be implemented as the negation of 
__eq, although it may default to that when no __ne is supplied.

There is an efficiency argument as well.  If two matrices differ
in the first element, one can immediately exit __ne, whereas you
would need to check the whole lot to evaluate __eq.

Actually, all six comparisons should be available as metamethods,
even if defaults are used to supply the missing ones.  As in P*****.