June 2010
Intermediate to advanced
456 pages
14h 48m
English
Type qualifiers capture important assertions about types in a language. Such assertions are highly useful to programmers and compilers alike but are difficult to capture by using conventions, regular subtyping (§ 6.4.2 on page 192), or type parameterization (§ 6.14 on page 233).
The canonical example of a type qualifier is const (introduced by C and refined by C++), which, when attached to a type T, expresses the assertion that T values can be initialized and read but never written to. The compiler ensures that the assertion is observed. The const qualifier is quite useful at module boundaries because it gives callers guarantees about functions. For example, the signature
// C standard function ...