ACM Home Page
Please provide us with feedback. Feedback
Covariance and contravariance: conflict without a cause
Full text PdfPdf (1.26 MB)
Source ACM Transactions on Programming Languages and Systems (TOPLAS) archive
Volume 17 ,  Issue 3  (May 1995) table of contents
Pages: 431 - 447  
Year of Publication: 1995
ISSN:0164-0925
Author
Giuseppe Castagna  C.N.R.S
Publisher
ACM  New York, NY, USA
Bibliometrics
Downloads (6 Weeks): 16,   Downloads (12 Months): 179,   Citation Count: 30
Additional Information:

abstract   references   cited by   index terms   review   collaborative colleagues  

Tools and Actions: Request Permissions Request Permissions    Review this Article  
DOI Bookmark: Use this link to bookmark this Article: http://doi.acm.org/10.1145/203095.203096
What is a DOI?

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 &lgr;&-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


REFERENCES

Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.

 
1
APPLE COMPUTER INC 1992. Dylan: An Ob3ect-Oriented Dynamic Language. Eastern Research and Technology, Apple Computer Inc., Cambridge, Mass.
 
2
 
3
 
4
CARDELLI, L. AND MITCHELL, J. 1991. Operations on records. Math. Struct. Comput. Scu 1, 1, 3-48.
 
5
 
6
CASTAGNA, G. 1995b. A proposal for making 02 more type safe. Tech. Rep. LIENS- 95-4, LIENS, Paris, France. Available by anonymous ftp from ftp.ens.fr in file /pub/dmi/users/castagna/o2.dvi. Z.
 
7
CASTAGNA, G. 1994. Overloading, subtyping and late binding: Functional foundation of objectoriented programming. Ph.D. thesis, Universit@ Paris 7, Paris, France. Appeared as LIENS Tech. Rep.
 
8

CITED BY  30


REVIEW

"Danny B. Lange : Reviewer"

Ever since the O2 data model [1] and later the Eiffel language [2] introduced the concept of covariant specialization of methods, type theorists have argued whether it is better to use covariant or contravariant specializa  more...