|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DeLesley Hutchins, The power of symmetry: unifying inheritance and generative programming, Companion of the 18th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, October 26-30, 2003, Anaheim, CA, USA
|
|
|
|
|
|
Curtis Clifton , Todd Millstein , Gary T. Leavens , Craig Chambers, MultiJava: Design rationale, compiler implementation, and applications, ACM Transactions on Programming Languages and Systems (TOPLAS), v.28 n.3, p.517-575, May 2006
|
|
|
|
|
|
|
|
|
Eric Allen , J. J. Hallett , Victor Luchangco , Sukyoung Ryu , Guy L. Steele, Jr., Modular multiple dispatch with multiple inheritance, Proceedings of the 2007 ACM symposium on Applied computing, March 11-15, 2007, Seoul, Korea
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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...
|