On Sat, May 17, 2025 at 12:07:40PM -0400, Nikolaos Chatzikonstantinou wrote:
> 
> I wonder if a plugin system that extends the language is a potential
> idea to explore. It could transform certain slower native m4 functions
> to e.g. Python or Scheme functions (because I'm considering rewriting
> this in Guile one day... I do not know what compels me to always think
> of reimplementing stuff). Of course m4-native functions can always be
> written since m4 is Turing complete, but they may be inefficient.

In fact, branch-2.0 in m4.git does just that - it has experimental
code to allow loadable modules, where you can write new builtins in
any language, and as long as the .so fits the ABI that m4 expects,
dynamically expand the language at runtime.  The problem is that it
has been years since anyone has tried to work on that branch (even
longer than what has gone into branch-1.6).  What's more, there are so
few m4 programmers out there that you are going to have a hard time
convincing anyone to use a faster m4 with plugin modules, when they
can just use a faster language with more community knowledge from the
get-go.

And speaking of Turing complete, Doug McIlroy has an interesting demo
at how not only is m4 Turing complete with all of its builtins, but if
you strip it down to JUST the define macro, it is still Turing
complete:

https://www.tuhs.org/mailman3/hyperkitty/list/t...@tuhs.org/thread/7ZRYUMZ2QNKE24QWUFT7MRK74COT7BIQ/

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.
Virtualization:  qemu.org | libguestfs.org


Reply via email to