2 ms·
While 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.
by wahern 5y ago
While 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.