Covariance and contravariance: conflict without a cause
In this chapter we expand the discussion started in Section 4.6.4. We argue that covariance and contravariance appropriately characterize two distinct and independent mechanisms. The so-called contravariance rule correctly captures substitutivity, or the subtyping relation (that establishes which sets of codes can replace in every context another given set). Instead, a covariant relation characterizes the specialization of code (i.e., the definition of new code that replaces the old one in some particular cases).
KeywordsCovariant Specialization Binary Method Small Talk Type Safety Inheritance Hierarchy
Unable to display preview. Download preview PDF.