15-312 Foundations of Programming Languages
Lecture 20: Dynamic Typing
In this lecture we consider relaxing our principle to detect all
type errors as early as possible. Instead, we do not apply any
type-checking at all, but just run the program. Surprisingly,
we can still state and prove a progress and preservation theorem
if we check for type errors at run-time and enter an appropriate
To implemented dynamic typing in the form above we need to
introduce tags so we can tell apart, for example, integers
and pointers. Then it is a small step towards introducing
tags directly in the source language, and we see that a dynamically
typed language can be implemented quite easily in a statically
typed language with tags.
Finally, we consider name-based subtyping systems as used
in object-oriented languages, and the form of dynamic typing
that arises in these languages.