Chapter 4. Running Code at Compile Time
The title of this chapter refers to Compile Time Function Execution (CTFE). This is primarily what makes D's generative programming capability as powerful as it is. Given that a function meets certain constraints, the compiler can execute it in order to produce values at compile time. These can then be used to generate new code. The very basics of CTFE can be explained with a couple of paragraphs, but there are a number of related features that can be used to increase its benefits. These features can also be used independently to conditionally control which parts of the program are compiled, or to generate code without ever running a function. We're going to spend the entire chapter examining these features in preparation for the next chapter on templates; D's compile-time features coupled with templates make for amazing possibilities.
- Pragmas: Compile-time messages, libraries, and function inlining hints
- Conditional compilation...