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

Frank Kastenholz <[email protected]> Sat, 4 Jul 2026 10:31:53 -0400
Newsgroups gmane.comp.lang.lua.general
Message-ID <[email protected]>

> On Jul 4, 2026, at 8:18 AM, 'Andrew' via lua-l <[email protected]> wrote:
> 
> 
> 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.


Did something similar to a complex number library; you could say something like “if (complex_number == 10)” and it would convert the 10 to “10+0i”.

The bigger mod I led was a prototype system where we had to be able to A) suspend a running Lua application (including library calls) whenever the host system sent us a signal of some sort and B) be able to simultaneously run multiple Lua applications/ For various reasons coroutines were not useful in this project. Also, we could not use pthreads since the project was targeted for a large group of systems with a wide range of host operating systems (I use that term loosely!). We ended up turning the virtual machine main loop into a preemptive multitasking kernel where the “processes” where Lua states. For other security reasons we ended up replacing or removing a lot of the standard library calls - the new versions lived within these constraints (for example, the string rep function’s main loop was modified to do “only a few” passes at a time, before ceding control.

It seemed to work quite well. But it was a prototype, so there probably were lots of corner cases we had missed at the time. As far as I know, the prototype was never picked up.

And. No, patches are not available :-(

Frank Kastenholz


-- 
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/212D269E-45AE-4B2B-88CC-48798DF5F700%40kastenholz.org.