[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: __eq operator behavior
- From: HyperHacker <hyperhacker@...>
- Date: Wed, 30 Mar 2011 06:35:23 -0600
On Wed, Mar 30, 2011 at 02:16, Dirk Laurie <email@example.com> wrote:
> 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*****.
The problem isn't when A == A, it's when A == B, but because A and B
are represented by two different tables, the result is false.
Sent from my toaster.