lua-users home
lua-l archive

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

On 09/06/2022 02:09, Andrew wrote:
Hi Eduardo,


Nathan's patch modifies the behaviour of the __eq metamethod so it
might (and almost certainly will) break some existing code. That's
why I suggest adding a new metamethod to 'fill in the gap'.

This way, the change is completely backwards compatible. There
should not be any code which puts an entry called '__eqval' into the
metatable, since all identifiers starting with '__' are reserved for
use by Lua.

My patch introduces a slight performance penalty on all comparisons
with a constant,

This might be a showstopper. Affecting every simple comparison just to save some hassles in a corner case that a minority of users would be interested in. IMO, that's a big "no, no", unless one could show me that the impact is extremely limited (say under 1% slowdown for code that *don't* make use of __eqval).

and an extra search for the __eqval metamethod iff
one of the operands to '==' or '~=' is a table or userdata.

This probably would be irrelevant in most cases.

I'm not very familiar with the internals of the VM, so it's probably
possible to implement the feature more efficiently.



-- Lorenzo