skip to main content
research-article

CZ: multiple inheritance without diamonds

Published:25 October 2009Publication History
Skip Abstract Section

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.

References

  1. R. Agrawal, L. DeMichiel, and B. Lindsay. Static type checking of multi-methods. In OOPSLA, pages 113--128, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle Scholar
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. D. Ancona and E. Zucca. An algebraic approach to mixins and modularity. In Algebraic and Logic Programming, pages 179--193, 1996. Google ScholarGoogle ScholarCross RefCross Ref
  6. 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 ScholarGoogle Scholar
  7. A. Bergel. Personal communication, October 2008.Google ScholarGoogle Scholar
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. L. Bettini, V. Bono, and S. Likavec. A core calculus of higher-order mixins and classes. In SAC, pages 1508--1509, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. J. Bloch. Effective Java: Programming Language Guide. Addison-Wesley, 2001.Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. J. Boyland and G. Castagna. Parasitic methods: An implementation of multi-methods for Java. In OOPSLA, pages 66--76, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. G. Bracha and W. Cook. Mixin-based inheritance. In ECOOP '90, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. B. Carré and J. Geib. The point of view notion for multiple inheritance. In OOPSLA/ECOOP '90, pages 312--321. ACM, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. C. Chambers. Object-oriented multi-methods in Cecil. In ECOOP '92, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle Scholar
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. W. Cook, W. Hill, and P. Canning. Inheritance is not subtyping. In POPL, pages 125--135, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. T. Ekman and G. Hedin. JastAdd. http://www.jastadd.org, 2008. Accessed 3/09.Google ScholarGoogle Scholar
  21. M. Ellis and B. Stroustrup. The Annotated C++ Reference Manual. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. R.B. Findler and M. Flatt. Modular object-oriented programming with units and mixins. ACM SIGPLAN Notices, 34(1):94--104, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle Scholar
  24. M. Flatt, S. Krishnamurthi, and M. Felleisen. Classes and mixins. In POPL '98, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. C. Frost and T. Millstein. Modularly typesafe interface dispatch in JPred. In FOOL/WOOD'06, January 2006.Google ScholarGoogle Scholar
  26. D. Hovemeyer and W. Pugh. Finding bugs is easy. SIGPLAN Not., 39(12):92--106, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. N. C. Hutchinson. EMERALD: An object-based language for distributed programming. PhD thesis, University of Washington, Seattle, WA, USA, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. A. Igarashi, B. Pierce, and P. Wadler. Featherwieght Java: a Minimal Core Calculus for Java and GJ. In OOPSLA '99, November 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  30. D. Malayeri. CZ: Multiple inheritance without diamonds. In FOOL '09, January 2009.Google ScholarGoogle Scholar
  31. 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 ScholarGoogle ScholarCross RefCross Ref
  32. B. Meyer. Object-Oriented Software Construction, 2nd Edition. Prentice-Hall, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  34. 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 ScholarGoogle Scholar
  35. T. Millstein, C. Bleckner, and C. Chambers. Modular typechecking for hierarchically extensible datatypes and functions. In ICFP '02, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  37. T. Millstein and C. Chambers. Modular statically typed multimethods. Inf. Comput., 175(1):76--118, 2002.Google ScholarGoogle ScholarCross RefCross Ref
  38. N. Nystrom, S. Chong, and A. Myers. Scalable extensibility via nested inheritance. In OOPSLA '04, pages 99--115, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. M. Odersky. The Scala language specification. Available at http://www.scala-lang.org/docu/files/ScalaReference.pdf, 2007. Accessed 3/09.Google ScholarGoogle Scholar
  40. M. Odersky and M. Zenger. Scalable Component Abstractions. In OOPSLA '05, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. A. Paepcke. Object-Oriented Programming: The CLOS Perspective. The MIT Press, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. P. Pirkelbauer, Y. Solodkyy, and B. Stroustrup. Open multi-methods for C++. In GPCE '07, pages 123--134, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. M. Sakkinen. Disciplined inheritance. In ECOOP, pages 39--56, 1989.Google ScholarGoogle Scholar
  44. N. Scharli, S. Ducasse, O. Nierstrasz, and A.P. Black. Traits: Composable Units of Behaviour. In ECOOP '03. Springer, 2003.Google ScholarGoogle Scholar
  45. A. Shalit. The Dylan Reference Manual: The Definitive Guide to the New Object-Oriented Dynamic Language. Addison-Wesley, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. G. Singh. Single versus multiple inheritance in object oriented programming. SIGPLAN OOPS Mess., 5(1):34--43, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. A. Snyder. Encapsulation and inheritance in object-oriented programming languages. In OOPSLA, pages 38--45, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. G. L. Steele, Jr. Common LISP: The Language. Digital Press, second edition, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  50. G. Washburn. Personal communication, December 2008.Google ScholarGoogle Scholar

Index Terms

  1. CZ: multiple inheritance without diamonds

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 44, Issue 10
      OOPSLA '09
      October 2009
      554 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/1639949
      Issue’s Table of Contents
      • cover image ACM Conferences
        OOPSLA '09: Proceedings of the 24th ACM SIGPLAN conference on Object oriented programming systems languages and applications
        October 2009
        590 pages
        ISBN:9781605587660
        DOI:10.1145/1640089

      Copyright © 2009 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 25 October 2009

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!