lua-users home
lua-l archive

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


On 30 March 2011 19:28, Drake Wilson <drake@begriffli.ch> wrote:
> Quoth Dirk Laurie <dpl@sun.ac.za>, on 2011-03-30 10:16:16 +0200:
>> 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.
>
> Really?  Why?
>
>   ---> Drake Wilson
>

For eg:
v={1,2,3,4,5}
u={2,4,6,8,10}

u==v would have to iterate over every value to check equality.
not u==v still iterates over the whole object
whereas u~=v can bail on the first index (1~=2)

In general, I'm not too sure about the merit of a __ne metamethod;
'a~=b' possibly returning a different result to 'not a==b'

Daurn.