Abstract
Multiple inheritance has long been plagued with the "diamond" inheritance problem, leading to solutions that restrict expressiveness, such as mixins and traits. Instead, we address the diamond problem directly, considering two difficulties it causes: ensuring a correct semantics for object initializers, and typechecking multiple dispatch in a modular fashion-the latter problem arising even with multiple interface inheritance. We show that previous solutions to these problems are either unsatisfactory or cumbersome, and suggest a novel approach: supporting multiple inheritance but forbidding diamond inheritance. Expressiveness is retained through two features: a "requires" construct that provides a form of subtyping without inheritance (inspired by Scala), and a dynamically-dispatched "super" call similar to that found in traits. Through examples, we illustrate that inheritance diamonds can be eliminated via a combination of "requires" and ordinary inheritance. We provide a sound formal model for our language and demonstrate its modularity and expressiveness.
- R. Agrawal, L. DeMichiel, and B. Lindsay. Static type checking of multi-methods. In OOPSLA, pages 113--128, 1991. Google Scholar
Digital Library
- E. Allen, D. Chase, J. Hallett, V. Luchangco, J. Maessen, S. Ryu, G. Steele, Jr., and S. Tobin-Hochstadt. The Fortress Language Specification, Version 1.0. Available at http://research.sun.com/projects/plrg/Publications/fortress.1.0.pdf, 2008. Accessed 3/09.Google Scholar
- E. Allen, J. J. Hallett, V. Luchangco, S. Ryu, and G. L. Steele Jr. Modular multiple dispatch with multiple inheritance. In SAC '07, pages 1117--1121. ACM, 2007. Google Scholar
Digital Library
- D. Ancona, G. Lagorio, and E. Zucca. Jam - designing a Java extension with mixins. ACM Trans. Program. Lang. Syst., 25(5):641--712, 2003. Google Scholar
Digital Library
- D. Ancona and E. Zucca. An algebraic approach to mixins and modularity. In Algebraic and Logic Programming, pages 179--193, 1996. Google Scholar
Cross Ref
- G. Baumgartner, M. Jansche, and K. Laufer. Half&Half: Multiple dispatch and retroactive abstraction for Java. Technical Report OSU-CISRC-5/01-TR08, Dept. of Computer and Information Science, The Ohio State University, March 2002.Google Scholar
- A. Bergel. Personal communication, October 2008.Google Scholar
- A. Bergel, S. Ducasse, O. Nierstrasz, and R. Wuyts. Stateful traits and their formalization. Computer Languages, Systems&Structures, 34(2-3):83--108, 2008. Google Scholar
Digital Library
- L. Bettini, V. Bono, and S. Likavec. A core calculus of higher-order mixins and classes. In SAC, pages 1508--1509, 2004. Google Scholar
Digital Library
- J. Bloch. Effective Java: Programming Language Guide. Addison-Wesley, 2001.Google Scholar
Digital Library
- J. Boyland and G. Castagna. Parasitic methods: An implementation of multi-methods for Java. In OOPSLA, pages 66--76, 1997. Google Scholar
Digital Library
- G. Bracha and W. Cook. Mixin-based inheritance. In ECOOP '90, 1990. Google Scholar
Digital Library
- B. Carré and J. Geib. The point of view notion for multiple inheritance. In OOPSLA/ECOOP '90, pages 312--321. ACM, 1990. Google Scholar
Digital Library
- C. Chambers. Object-oriented multi-methods in Cecil. In ECOOP '92, 1992. Google Scholar
Digital Library
- C. Chambers and the Cecil Group. The Cecil language: specification and rationale, Version 3.2. Available at http://www.cs.washington.edu/research/projects/cecil/, 2004. Accessed 3/09.Google Scholar
- C. Clifton, G. T. Leavens, C. Chambers, and T. Millstein. MultiJava: modular open classes and symmetric multiple dispatch for Java. In OOPSLA '00, pages 130--145, 2000. Google Scholar
Digital Library
- C. Clifton, T. Millstein, G. T. Leavens, and C. Chambers. MultiJava: Design rationale, compiler implementation, and applications. ACM Trans. Program. Lang. Syst., 28(3):517--575, 2006. Google Scholar
Digital Library
- W. Cook, W. Hill, and P. Canning. Inheritance is not subtyping. In POPL, pages 125--135, 1990. Google Scholar
Digital Library
- S. Ducasse, O. Nierstrasz, N. Scharli, R. Wuyts, and A.P. Black. Traits: A mechanism for fine-grained reuse. ACM Trans. Program. Lang. Syst., 28(2):331--388, 2006. Google Scholar
Digital Library
- T. Ekman and G. Hedin. JastAdd. http://www.jastadd.org, 2008. Accessed 3/09.Google Scholar
- M. Ellis and B. Stroustrup. The Annotated C++ Reference Manual. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1990. Google Scholar
Digital Library
- R.B. Findler and M. Flatt. Modular object-oriented programming with units and mixins. ACM SIGPLAN Notices, 34(1):94--104, 1999. Google Scholar
Digital Library
- K. Fisher and J. Reppy. A typed calculus of traits. In Proceedings of the 11th Workshop on Foundations of Object-oriented Programming, January 2004.Google Scholar
- M. Flatt, S. Krishnamurthi, and M. Felleisen. Classes and mixins. In POPL '98, 1998. Google Scholar
Digital Library
- C. Frost and T. Millstein. Modularly typesafe interface dispatch in JPred. In FOOL/WOOD'06, January 2006.Google Scholar
- D. Hovemeyer and W. Pugh. Finding bugs is easy. SIGPLAN Not., 39(12):92--106, 2004. Google Scholar
Digital Library
- N. C. Hutchinson. EMERALD: An object-based language for distributed programming. PhD thesis, University of Washington, Seattle, WA, USA, 1987. Google Scholar
Digital Library
- A. Igarashi, B. Pierce, and P. Wadler. Featherwieght Java: a Minimal Core Calculus for Java and GJ. In OOPSLA '99, November 1999. Google Scholar
Digital Library
- E. Johnsen, O. Owe, and I. Yu. Creol: A type-safe object-oriented model for distributed concurrent systems. Theor. Comput. Sci., 365(1):23--66, 2006. Google Scholar
Digital Library
- D. Malayeri. CZ: Multiple inheritance without diamonds. In FOOL '09, January 2009.Google Scholar
- D. Malayeri and J. Aldrich. CZ: Multimethods and multiple inheritance without diamonds. Technical Report CMU-CS-09-153, School of Computer Science, Carnegie Mellon University, August 2009.Google Scholar
Cross Ref
- B. Meyer. Object-Oriented Software Construction, 2nd Edition. Prentice-Hall, 1997. Google Scholar
Digital Library
- S. Meyers. Effective C++: 50 specific ways to improve your programs and designs. Addison Wesley Longman Publishing Co., Inc. Redwood City, CA, USA, 1992. Google Scholar
Digital Library
- Microsoft Corporation. C# language specification, version 3.0. Available at http://download.microsoft.com/download/3/8/8/388e7205-bc10-4226-b2a8-75%351c669b09/csharp%20language%20specification.doc, 2007. Accessed 8/09.Google Scholar
- T. Millstein, C. Bleckner, and C. Chambers. Modular typechecking for hierarchically extensible datatypes and functions. In ICFP '02, 2002. Google Scholar
Digital Library
- T. Millstein, C. Bleckner, and C. Chambers. Modular typechecking for hierarchically extensible datatypes and functions. ACM Trans. Program. Lang. Syst., 26(5):836--889, 2004. Google Scholar
Digital Library
- T. Millstein and C. Chambers. Modular statically typed multimethods. Inf. Comput., 175(1):76--118, 2002.Google Scholar
Cross Ref
- N. Nystrom, S. Chong, and A. Myers. Scalable extensibility via nested inheritance. In OOPSLA '04, pages 99--115, 2004. Google Scholar
Digital Library
- M. Odersky. The Scala language specification. Available at http://www.scala-lang.org/docu/files/ScalaReference.pdf, 2007. Accessed 3/09.Google Scholar
- M. Odersky and M. Zenger. Scalable Component Abstractions. In OOPSLA '05, 2005. Google Scholar
Digital Library
- A. Paepcke. Object-Oriented Programming: The CLOS Perspective. The MIT Press, 1993. Google Scholar
Digital Library
- P. Pirkelbauer, Y. Solodkyy, and B. Stroustrup. Open multi-methods for C++. In GPCE '07, pages 123--134, 2007. Google Scholar
Digital Library
- M. Sakkinen. Disciplined inheritance. In ECOOP, pages 39--56, 1989.Google Scholar
- N. Scharli, S. Ducasse, O. Nierstrasz, and A.P. Black. Traits: Composable Units of Behaviour. In ECOOP '03. Springer, 2003.Google Scholar
- A. Shalit. The Dylan Reference Manual: The Definitive Guide to the New Object-Oriented Dynamic Language. Addison-Wesley, 1997. Google Scholar
Digital Library
- G. Singh. Single versus multiple inheritance in object oriented programming. SIGPLAN OOPS Mess., 5(1):34--43, 1994. Google Scholar
Digital Library
- A. Snyder. Encapsulation and inheritance in object-oriented programming languages. In OOPSLA, pages 38--45, 1986. Google Scholar
Digital Library
- G. L. Steele, Jr. Common LISP: The Language. Digital Press, second edition, 1990. Google Scholar
Digital Library
- C. Szyperski, S. Omohundro, and S. Murer. Engineering a programming language: The type and class system of Sather. In J. Gutknecht, editor, Programming Languages and System Architectures, volume 782 of Lecture Notes in Computer Science. Springer, 1993. Google Scholar
Digital Library
- G. Washburn. Personal communication, December 2008.Google Scholar
Index Terms
CZ: multiple inheritance without diamonds
Recommendations
CZ: multiple inheritance without diamonds
OOPSLA '09: Proceedings of the 24th ACM SIGPLAN conference on Object oriented programming systems languages and applicationsMultiple inheritance has long been plagued with the "diamond" inheritance problem, leading to solutions that restrict expressiveness, such as mixins and traits. Instead, we address the diamond problem directly, considering two difficulties it causes: ...
Type checking modular multiple dispatch with parametric polymorphism and multiple inheritance
OOPSLA '11In previous work, we presented rules for defining overloaded functions that ensure type safety under symmetric multiple dispatch in an object-oriented language with multiple inheritance, and we showed how to check these rules without requiring the ...
CZ: multiple inheritance without diamonds
OOPSLA Companion '08: Companion to the 23rd ACM SIGPLAN conference on Object-oriented programming systems languages and applicationsMultiple inheritance has long been plagued with the "diamond" inheritance problem, spurring a variety of solutions, such as virtual inheritance, mixins and traits. We offer a different solution: a language that supports multiple inheritance but forbids ...







Comments