Skip to Main Content
Language Implementation Patterns
book

Language Implementation Patterns

by Terence Parr
December 2009
Intermediate to advanced content levelIntermediate to advanced
380 pages
9h 2m
English
Pragmatic Bookshelf
Content preview from Language Implementation Patterns
Pattern 22Enforcing Static Type Safety

Purpose

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.

Discussion

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.

  1. if conditionals must evaluate to a boolean

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Implementation Patterns

Implementation Patterns

Kent Beck

Publisher Resources

ISBN: 9781680500097Errata Page