ACM Transactions on Programming Languages and Systems · 1995 · 170 citations · 10 references
ComputingComputer ScienceProgramming LanguagesSoftware EngineeringTheory Of ComputationData TypesModel TheoryObject-oriented DesignObject-oriented ProgrammingType CheckingType SystemsCovarianceType Safety
In type-theoretic research on object-oriented programming, the issue of “covariance versus contravariance” is a topic of continuing debate. In this short note we argue that covariance and contravariance appropriately characterize two distinct and independent mechanisms. The so-called contravariance rule correctly captures the subtyping relation (that relation which establishes which sets of functions can replace another given set in every context ). A covariant relation, instead, characterizes the specialization of code (i.e., the definition of new code which replaces old definitions in some particular cases ). Therefore, covariance and contravariance are not opposing views, but distinct concepts that each have their place in object-oriented systems. Both can (and should) be integrated in a type-safe manner in object-oriented languages. We also show that the independence of the two mechanisms is not characteristic of a particular model but is valid in general, since covariant specialization is present in record-based models, although it is hidden by a deficiency of all existing calculi that realize this model. As an aside, we show that the λ&-calculus can be taken as the basic calculus for both an overloading-based and a record-based model. Using this approach, one not only obtains a more uniform vision of object-oriented type theories, but in the case of the record-based approach, one also gains multiple dispatching, a feature that existing record-based models do not capture
10
A semantics of multiple inheritance
Luca Cardelli · Information and Computation · 1988 · 627 citations
Language Studies, World Languages, Knowledge Representation +7
Complete Type Inference for Simple Objects
Mitchell Wand · Logic in Computer Science · 1987 · 211 citations
Type checking records and variants in a natural extension of ML
Didier Rémy · 1989 · 205 citations · Full text
Computing, Computer Science, Natural Language Processing +12