4 ms·
There's always M4, which will preprocess just about anything you throw at it. The syntax starts off pretty godawful, but eventually you learn to love it. C# an
by PeCaN 11y ago
There's always M4, which will preprocess just about anything you throw at it.
The syntax starts off pretty godawful, but eventually you learn to love it. C# and Java are much nicer with a little M4.
Everybody loves to hate on text-substitution macros (and hey, I write parsers and such, I'm a Smug Lisp Weenie, and generally I know how easy it is to break something and how much better real macros are), but sometimes they actually are the right tool for the job. Just because they're sometimes very much the wrong tool doesn't mean they should be kept out of your toolbox. Until all languages are either Lisp-ish or Forth-ish, I will maintain that there is a place for CPP/M4/etc. :-)
M4 is seriously awesome, just remember: with great text substitution comes great attention to detail. And heed the warning from the manual[1]:
> Some people find m4 to be fairly addictive. They first use m4 for simple problems, then take bigger and bigger challenges, learning how to write complex sets of m4 macros along the way. Once really addicted, users pursue writing of sophisticated m4 applications even to solve simple problems, devoting more time debugging their m4 scripts than doing real work. Beware that m4 may be dangerous for the health of compulsive programmers.
1. https://www.gnu.org/software/m4/manual/m4.html https://www.gnu.org/software/m4/manual/m4.html
- generic_user 11y agoM4 is a great tool. A good chunk of programmers now seem to have never been exposed to pre processors and what you can do with them, its a shame really.
- speps 11y agoFor C# based environments, you should use T4[1] actually. It comes with Mono[2] as well as the normal CLR. It has an API and a command-line tool. [1]: https://msdn.microsoft.com/en-us/library/bb126445.aspx https://msdn.microsoft.com/en-us/library/bb126445.aspx [2]: https://github.com/mono/monodevelop/tree/master/main/src/addins/TextTemplating/TextTransform https://github.com/mono/monodevelop/tree/master/main/src/add...