A monetary amount is a domain-specific attribute type for values measured in dollars. It distinguishes money from other numeric-looking values: $3.0 is not 3.0% or 300%. The attribute type determines both which values a record can hold and how its generated Runtime code handles them. section 1.2.1 section 13.0
Use monetary amounts for business values such as rental prices. An attribute can declare this type and optionally use an initial-value expression that produces an amount. Type checking compares the declared attribute type with the expression’s computed type, helping prevent nonsensical combinations before they produce faulty Runtime behavior. section 1.2.1 section 13.0
Type computation preserves the amount type through supported rental-price operations:
- An attribute reference has the declared type of the attribute it refers to; a reference to rental price before discount therefore has type amount. section 13.1
- Taking a percentage of an amount produces an amount. section 13.1
- Subtracting two amounts produces an amount. section 13.1
- A parenthesized expression has the type of its enclosed subexpression. section 13.1
Discounted rental price
For rental price before discount − discount of rental price before discount, both price references are amounts and discount is a percentage. Compute the of operation first: percentage of amount is amount. Subtracting the resulting amount from the original amount leaves the whole expression with type amount. section 13.1
Figure 13.5 The type computation of the rental price expression, in terms of the AST
Inspect the expression AST as types are computed from its leaves upward, culminating in an amount for the complete rental-price expression. section 13.1

