3 ms·
Is there any large body of public C code that uses/used m4? I'd really like to see what the m4 equivalent of the original Bourne shell code or the APL Incunabul
by mhd 5y ago
Is there any large body of public C code that uses/used m4? I'd really like to see what the m4 equivalent of the original Bourne shell code or the APL Incunabulum would be.
- lazyjones 5y agoHow large does that body have to be? Autoconf consists of M4 macros, so all software that uses Autoconf uses m4.
- habibur 5y agom4 is used heavily in application build systems.
- wahern 5y agoWhile Turing complete, and not merely in a highly technical, obtuse way (e.g. C++ templates), m4 nonetheless doesn't work well with dynamic or arbitrary inputs. I'm sure you can make it work using extensions like GNU Make's esyscmd and some preprocessing, but it would be ugly and even more impenetrable than typical recursive string interpolation code. To reimplement complex software you'd probably end up implementing a tiny VM in m4 and then targeting the VM. Though, I suppose m4 is far more accommodating in this regard than, e.g., ed or sed. IOW, m4 is really only suited for fairly straight-forward static input-output transformations, such as common templating tasks. These transformations can themselves become quite complex and even convenient to implement (put your functional programming hat on), but once you stray from recursive string interpolation on lists of simple tokens sourced from statically defined input the ergonomics break down immediately.
- zajio1am 5y agoWe in BIRD (https://bird.network.cz/ https://bird.network.cz/) use m4 code (https://gitlab.nic.cz/labs/bird/-/blob/master/filter/decl.m4 https://gitlab.nic.cz/labs/bird/-/blob/master/filter/decl.m4) to implement bytecode interpreter for our filtering language.
- tjalfi 5y agoThe closest equivalent for macro processors is probably ML/I[0]. It’s implemented in macros[1]; you port it by defining macros that map it to a high level language or assembly language. William Waite’s Stage2[2], Robert Dewar’s Macro SPITBOL[3], and Macro SNOBOL4[4] are some other examples of systems implemented in macros. [0] http://www.ml1.org.uk/index.html http://www.ml1.org.uk/index.html [1] http://www.ml1.org.uk/implementation.html http://www.ml1.org.uk/implementation.html [2] https://github.com/crandylb/stage2-1 https://github.com/crandylb/stage2-1 [3] https://github.com/spitbol https://github.com/spitbol [4] https://www.snobol4.org/csnobol4/curr/ https://www.snobol4.org/csnobol4/curr/