Skip to main content

The world is covariant: is it safe?

Professor Bertrand Meyer ( Software Engineering, ETH Zurich )

One of the principal attractions of object technology is its power as a modeling tool, ensuring a close correspondence between the structure of programs and that of the world elements they model. Experience shows that effective modeling calls for a "covariant" policy where types, arguments and results all change in the direction of the inheritance hierarchy. A naïve covariant implementation, however, leads to an unsound type system. Genericity makes the problem even thornier.

Over the past two decades many solutions have been pondered, but none has gained wide acceptance, and many O-O languages remain novariant for lack of an approach guaranteed safe.

After a review of the issue and previous solutions I will present a new one, recently implemented with some success, and discuss whether it puts the issue to rest.

Share this: