Static typing refers to types declared in a program at compile-time, so no type information is available on objects at run-time. Dynamic typing uses the inherent types of polymorphic objects, keeping track of the types of objects at run-time. Statically typed dynamic binding is a compromise (usually implemented with tables of function pointers and offsets), and is how statically-typed OO languages provide polymorphism. Some approaches provide both static and dynamic typing, sometimes with static typing providing type- safe programs and dynamic typing providing multiple-polymorphism [Agrawal 91] [Mugridge 91]. See also section 2.3.
Static typing is more efficient and reliable, but loses power. Typical restrictions include only allowing a common set of base class functions (or any common functions for the more general subtyping or parametric polymorphic cases) to be available on formal objects and a lack of multiple-polymorphism (see section 1.19), both of which are overcome with dynamic typing.
Many languages provide dynamic typing: Smalltalk, Self, Objective-C, and etc. A limited dynamic typing scheme, called RTTI (Run Time Type Identification), is even being considered for the C++ standard. A similar facility to safe downcasting (historically known as type narrowing), the thrust of RTTI, can also be found in recent versions of Eiffel.
See section 3.4 for a categorization of common OO languages by type system.
This document was translated by ms2html v1.8 on 01.06.95.