HP Labs Technical Reports
Click here for full text:
Contravariance for the Rest of Us
Abstract: Recent research has demonstrated that subtyping and inheritance are distinct relationships. Primarily, the difference arises because of something called Contravariance and its effects on object-oriented programming. Contravariance is a phenomenon which occurs as an interaction between subtyping and higher-order functions, and has important implications for object-oriented programming. It affects all object-oriented programming languages, including C++, and is usually circumvented by overloading. However, overloading does not always have the desired effect, which we will illustrate with actual C++ examples. Finally, we will discuss what a better - more expressive and type safe - language might look like.
Back to Index