chapter eleven
This chapter covers:
- Why, how, and for what expressions are very useful
- Why binary operations are especially useful
- How to represent expressions with binary operations as ASTs
- How to implement binary operations across all key aspects of a DSL
Looking at our example DSL content, we notice that the attributes of the “Rental” record type should be related more intricately than they currently are.
Figure 11.1. The relation between the values of the four attributes of the “Rental” record type.
The value of rental price after discount should be calculated from the values of rental price before discount and discount. Unfortunately, we can’t express such relations yet: the DSL doesn’t have any concept with the appropriate notation, and the corresponding meaning. Leaving it up to the user of the generated Web app to set the value of rental price after discount to a value governed by the arithmetical relation above, is unfair.