December 2009
Intermediate to advanced
380 pages
9h 2m
English
| Pattern 22 | Enforcing Static Type Safety |
This pattern statically detects incompatible types in expressions and statements.
You can extrapolate from this pattern everything you’d need to build a type safety checker for any statically typed language with explicit declarations like C. Tools such as compilers that translate or otherwise analyze a statically typed language need this pattern.
A static type checker adds type compatibility checks to Pattern 21, Automatic Type Promotion (which is, in turn, based upon Pattern 20, Computing Static Expression Types). We’re going to enforce the type compatibility checks described in Figure 23, The type compatibility rules Cymbol enforces.
if conditionals must evaluate to a boolean