December 2009
Intermediate to advanced
380 pages
9h 2m
English
We derive the meaning of a sentence from both its structure (syntax) and the particular vocabulary symbols it uses. The structure says what to do, and the symbols say what to do it to. For example, in phrase print x, the syntax says to print a value, and the symbol x says which value to print. Sometimes, though, we write code that make no sense even if the syntax is correct. Such programs violate a language’s semantic rules.
Languages typically have lots and lots of semantic rules. Some rules are run-time constraints (dynamic semantics), and some are compile-time constraints (static semantics). Dynamic semantic rules enforce things like “no division by zero” and “no array index out of bounds.” Depending ...