Chapter 4. Metaprogramming

Table of Contents
4.1. External filters
4.1.1. CPP
4.1.2. M4
4.1.3. Macroprocessing with your own filter
4.2. Metaprogramming
4.2.1. Backends from compilers
4.2.2. The New-Jersey Machine-Code Toolkit
4.2.3. TUNES

Assembly programming is a bore, but for critical parts of programs.

You should use the appropriate tool for the right task, so don't choose assembly when it does not fit; C, OCaml, perl, Scheme, might be a better choice in the most cases.

However, there are cases when these tools do not give fine enough control on the machine, and assembly is useful or needed. In these cases you'll appreciate a system of macroprocessing and metaprogramming that allows recurring patterns to be factored each into one indefinitely reusable definition, which allows safer programming, automatic propagation of pattern modification, etc. Plain assembler often is not enough, even when one is doing only small routines to link with C.