On Fri, May 09, 2025 at 04:33:44PM -0400, Nikolaos Chatzikonstantinou wrote: > Hello lists, > > I rewrote GNU m4 in Python. Long story short, I wanted to learn m4 to > fix some issues I had with GNU Guile and Autotools, and after > realizing m4 1.4 is ~8000 lines of code and reading e.g. > <https://www.owlfolio.org/development/autoconf-swot/> which claims > "Feature gaps in GNU M4 hold back development of Autoconf." I thought > I'd rewrite it in Rust. (It turned out to be more beneficial to > rewrite in Python due to faster prototyping for the time being.) > Eventually I plan to get back to my original purpose of fixing the > integration of GNU Guile and Autotools. > > You can find the project home page here, > <https://codeberg.org/annoyingusername/m4p> and you can install with > pip via `pip install m4p`. > > I'm hoping that this is a welcome addition. I'm interested to hear if > m4p works as a GNU m4 replacement for you, and any issues that arise.
I still need to test it for performance; off-hand, I'm skeptical that python can out-perform C, but until I actually benchmark things, you have a chance. > > I have not yet implemented: > > 1. traceon, traceoff, changeword, debugmode, debugfile, dumpdef traceon and dumpdef are mandated by POSIX. Don't bother implementing changeword (it's already ripped out of branch-1.6). debugmode is also going to be essential for controlling compatibility. > 2. Some of the command-line options. Does it handle frozen files yet? > > I'm worried about: > > 1. What mode GNU m4 opens files in; m4p always open in binary, > potentially treating carriage return differently on Windows. > 2. Sneaky bugs. > > The functions that I have not yet implemented are debug functions, so > they probably will not affect production m4 macros. The changeword > macro might be removed in future versions of GNU m4 and I might not > implement it at all, not sure if anyone uses it. I have not had any > benchmarks, but from roughly looking at > how long tests take I'm measuring a 100x slowdown. I'm hoping to > rewrite it in Rust later to address that. > > Regards, > Nikolaos Chatzikonstantinou > -- Eric Blake, Principal Software Engineer Red Hat, Inc. Virtualization: qemu.org | libguestfs.org