Abstract
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
Publisher
Association for Computing Machinery (ACM)
Reference6 articles.
1. BANCILHON F. DELOBEL C. AND KANELLAKIS P. (Eds.) 1992. Implementing an Object- Omented Database System: The Story of 02 Morgan Kaufmann San Mateo Cahf. BANCILHON F. DELOBEL C. AND KANELLAKIS P. (Eds.) 1992. Implementing an Object- Omented Database System: The Story of 02 Morgan Kaufmann San Mateo Cahf.
2. Operations on records;CARDELLI L.;Math. Struct. Comput. Scu,1991
3. CASTAGNA G. 1995a. A meta-language for typed object-oriented languages. Theor. Comput. Sc~. To be published. An extended abstract appears in Proceedings of the 13th Conference on the Foundatwns of Software Technology and Theoretical Computer Science. Lecture Notes in Computer Science vol. 761. Springer-Verlag New York 1993. CASTAGNA G. 1995a. A meta-language for typed object-oriented languages. Theor. Comput. Sc~. To be published. An extended abstract appears in Proceedings of the 13th Conference on the Foundatwns of Software Technology and Theoretical Computer Science. Lecture Notes in Computer Science vol. 761. Springer-Verlag New York 1993.
Cited by
84 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献