Re: Who is using modified Lua versions, what are they and why?

"'Andrew' via lua-l" <[email protected]> Sat, 4 Jul 2026 22:18:30 +1000
Newsgroups gmane.comp.lang.lua.general
Message-ID <[email protected]>
On 27/06/2026 10:54, 'Sewbacca' via lua-l wrote:
> ... 
> So out of curiosity: Who is using modified Lua versions, what are the 
> modifications and why do you need them?

I use a patch to add an extra metamethod '__eqval', which is called when 
only one of the operands to the compare-equal operator (==) is a table 
or userdata; if both operands are tables or both are userdata then only 
the '__eq' metamethod is called as usual. The overhead on 'normal' 
equality comparisons is minimal or zero.

This allows a library which implements a higher level data type (let's 
call it T) as a table or userdata to be used more naturally when 
comparing directly with a number or a string. For example, if p is a 
variable holding a value of type T, you can write 'p == 2' and the 
__eqval metamethod will be called (unless p is just a number too). 
Otherwise you would have to write 'p == convert-to-T(2)'. The same 
applies when comparing two variables, one of which may contain a T and 
the other a simple value (number, string or boolean).

I've used this metamethod in an infinite precision arithmetic library in 
pure lua. It allows code written in other languages (eg a crypto package 
written in C) to be imported into lua with minimal effort.

-a

[patch for 5.4 is on Lua Power Patches 
<http://lua-users.org/wiki/LuaPowerPatches>. If anyone is interested I 
will upload patches for later Lua versions]

> 
> ~ Sewbacca
> 
> -- 
> You received this message because you are subscribed to the Google 
> Groups "lua-l" group.
> To unsubscribe from this group and stop receiving emails from it, send 
> an email to [email protected] <mailto:lua- 
> [email protected]>.
> To view this discussion visit https://groups.google.com/d/msgid/lua-l/ 
> dbcab2ec-b0c0-46de-96de-68e7e7782044%40kolabnow.com <https:// 
> groups.google.com/d/msgid/lua-l/dbcab2ec- 
> b0c0-46de-96de-68e7e7782044%40kolabnow.com? 
> utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/10a21df5-0564-46ac-8310-750cddbf477e%40gmx.net.