lua-users home
lua-l archive

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


On Wed, Mar 30, 2011 at 02:16, Dirk Laurie <dpl@sun.ac.za> 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*****.
>
> Dirk
>
>
>

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.