Domain Control Structures
The code generation that was presented in the previous chapters covered basic conditional and loop control structures, but domain-specific languages often have unique or customized semantics that merit introducing novel control structures. Adding a new control structure is usually substantially more difficult than adding a new function or operator. However, when they are effective, the addition of domain control structures is a large part of what makes domain-specific languages worth developing instead of just writing class libraries. The examples in this chapter should support this assertion, but it is based on the Sapir-Whorf hypothesis, which claims that language influences and constrains what we are able to think. Programming languages that are Turing complete can compute anything, but that does not mean they are equally practical for all jobs. Adding domain control structures can make your language the most practical choice for some new application domains...