skip to main content
10.1145/1167473.1167475acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
Article

Eliminating distinctions of class: using prototypes to model virtual classes

Published:16 October 2006Publication History

ABSTRACT

In mainstream OO languages, inheritance can be used to add new methods, or to override existing methods. Virtual classes and feature oriented programming are techniques which extend the mechanism of inheritance so that it is possible to refine nested classes as well. These techniques are attractive for programming in the large, because inheritance becomes a tool for manipulating whole class hierarchies rather than individual classes. Nevertheless, it has proved difficult to design static type systems for virtual classes, because virtual classes introduce dependent types. The compile-time type of an expression may depend on the run-time values of objects in that expression.We present a formal object calculus which implements virtual classes in a type-safe manner. Our type system uses a novel technique based on prototypes, which blur the distinction between compile-time and run-time. At run-time, prototypes act as objects, and they can be used in ordinary computations. At compile-time, they act as types. Prototypes are similar in power to dependent types, and subtyping is shown to be a form of partial evaluation. We prove that prototypes are type-safe but undecidable, and briefly outline a decidable semi-algorithm for dealing with them.

References

  1. M. Abadi and L. Cardelli. A Theory of Objects. Springer, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. D. Aspinall. Subtyping with singleton types. Eighth International Workshop on Computer Science Logic, 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. D. Aspinall and A. Compagnoni. Subtyping dependent types. Proceedings of 11th Annual Symposium on Logic in Computer Science, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. L. Augustsson. Cayenne - a language with dependent types. International Conference on Functional Programming, pages 239--250, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. E. Barendsen and S. Smetsers. Uniqueness typing for functional languages with graph rewriting semantics. Mathematical Structures in Computer Science, 1996.]]Google ScholarGoogle ScholarCross RefCross Ref
  6. K. Barrett et al. A monotonic superclass linearization for dylan. Proceedings of OOPSLA, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. D. Batory, J. Liu, and J. Sarvela. Refinements and multi-dimensional separation of concerns. ACM SIGSOFT, 2003.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. D. Batory, J. Sarvela, and A. Rauschmayer. Scaling step-wise refinement. Proceedings of ICSE, 2003.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. G. Blaschek. Type-safe OOP with prototypes: the concepts of Omega. Structured Programming, 12(12):1--9, 1991.]]Google ScholarGoogle Scholar
  10. G. Bracha. The Programming Language Jigsaw: Mixins, Modularity and Multiple Inheritance. Ph.D. thesis, University of Utah, 1992.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. G. Bracha and W. Cook. Mixin-based inheritance. OOPSLA, 1990.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. K. Bruce. Some challenging typing issues in object-oriented languages. Electronic Notes in Theoretical Computer Science 82 No. 8, 2003.]]Google ScholarGoogle Scholar
  13. K. Bruce, A. Fiech, and L. Petersen. Subtyping is not a good "match" for object-oriented languages. Proceedings of ECOOP, 1997.]]Google ScholarGoogle ScholarCross RefCross Ref
  14. K. B. Bruce, M. Odersky, and P. Wadler. A statically safe alternative to virtual types. Proceedings of ECOOP, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. P. Canning, W. Cook, W. Hill, and W. Olthoff. F-bounded polymorphism for object-oriented programming. Proceedings of FPLCA, 1989.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. G. Chen. Subtyping calculus of constructions (extended abstract). Proceedings of the International Symposium on Mathematical Foundations of Computer Science, 1997.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. D. Clarke, S. Drossopoulou, J. Noble, and T. Wrigstad. Tribe: More types for virtual classes. In submission, 2005.]]Google ScholarGoogle Scholar
  18. A. Compagnoni and B. Pierce. Higher-order intersection types and multiple inheritance. Mathematical Structures in Computer Science, 6 (5):469--501, 1996.]]Google ScholarGoogle ScholarCross RefCross Ref
  19. W. Cook, W. Hill, and P. Canning. Inheritance is not subtyping. Proceedings of POPL, 1990.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. T. Coquand and G. Huet. The calculus of constructions. Information and Computation, 1(2/3), 1988.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. P. Cousot and R. Cousot. Abstract interpretation: A unified lattice model for static analysis of programs by construction or approximation of fixpoints. Proceedings of the 4th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, pages 238--252, 1977.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. D. Dreyer, R. Harper, and K. Crary. Toward a practical type theory for recursive modules. Technical Report CMU-CS-01-112, 2001.]]Google ScholarGoogle ScholarCross RefCross Ref
  23. D. Duggan and C. Sourelis. Mixin modules. Proceedings of the International Conference on Functional Programming, 1996.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. E. Ernst. gbeta - a Language with Virtual Attributes, Block Structure, and Propagating, Dynamic Inheritance. Ph.D. thesis. Department of Computer Science, University of Aarhus, Denmark, 1999.]]Google ScholarGoogle Scholar
  25. E. Ernst. Propagating class and method combination. Proceedings of ECOOP, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. E. Ernst. Family polymorphism. Proceedings of ECOOP, 2001.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. E. Ernst. Higher order hierarchies. Proceedings of ECOOP, 2003.]]Google ScholarGoogle ScholarCross RefCross Ref
  28. E. Ernst, K. Ostermann, and W. Cook. A virtual class calculus. Proceedings of POPL, 2006.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. M. Flatt, S. Krishnamurthi, and M. Felleisen. Classes and mixins. ACM Symposium on Principles of Programming Languages, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. D. Hutchins. The power of symmetry: Unifying inheritance and generative programming. OOPSLA Companion, DDD Track, 2003.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. A. Igarashi and B. Pierce. Foundations for virtual types. Proceedings of ECOOP, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. A. Igarashi, B. Pierce, and P. Wadler. Featherweight java, a minimal core calculus for java and gj. Proceedings of OOPSLA, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. A. Igarashi, C. Saito, and M. Viroli. Lightweight family polymorphism. Proceedings of the 3rd Asian Symposium on Programming Languages and Systems, 2005.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. P. Jolly, S. Drossopoulou, C. Anderson, and K. Ostermann. Simple dependent types: Concord. Proceedings of FTfJP, 2005.]]Google ScholarGoogle Scholar
  35. N. Jones, C. Gomard, and P. Sestoft. Partial Evaluation and Automatic Program Generation. Prentice-Hall, Inc. Upper Saddle River, NJ, USA, 1993.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. N. D. Jones and A. J. Glenstrup. Program generation, termination, and binding-time analysis. Proceedings of GPCE, 2002.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. R. Lopez-Herrejon, D. Batory, and W. Cook. Evaluating support for features in advanced modularization technologies. Proceedings of ECOOP, 2005.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Z. Luo. Computation and reasoning: a type theory for computer science. Oxford University Press, Inc., New York, NY, USA, 1994.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. O. Madsen and B. Møller-Pedersen. Virtual classes: A powerful mechanism in object-oriented programming. Proceedings of OOPSLA, 1989.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. C. McBride and J. McKinna. The view from the left. Journal of Functional Programming, 14(1):69--111, 2004.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. N. Nystrom, S. Chong, and A. Myers. Scalable extensibility via nested inheritance. Proceedings of OOPSLA, 2005.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. N. Nystrom, X. Qi, and A. Myers. J&: Nested intersection for scalable software composition. Proceedings of OOPSLA, 2006.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. M. Odersky, V. Cremet, C. Roeckl, and M. Zenger. A nominal theory of objects with dependent types. Proceedings of ECOOP, 2003.]]Google ScholarGoogle ScholarCross RefCross Ref
  44. W. H. Peri Tarr, H. Ossher. N degrees of separation: Multi-dimensional separation of concerns. Proceedings of ICSE, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. N. Schärli, S. Ducasse, O. Nierstrasz, and A. Black. Traits: Composable units of behavior. Proceedings of ECOOP, 2002.]]Google ScholarGoogle Scholar
  46. Y. Smaragdakis and D. Batory. Implementing layered designs with mixin layers. Proceedings of ECOOP, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. C. Stone. Singleton Kinds and Singleton Types. PhD thesis, Carnegie Mellon University, 2000.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. K. K. Thorup and M. Torgersen. Unifying genericity - combining the benefits of virtual types and parameterized classes. Proceedings of ECOOP, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. M. Torgersen. Virtual types are statically safe. 5th Workshop on Foundations of Object-Oriented Languages, 1998.]]Google ScholarGoogle Scholar
  50. M. Torgersen. The expression problem revisited. four new solutions using generics. Proceedings of ECOOP, 2004.]]Google ScholarGoogle Scholar
  51. D. Ungar and R. Smith. Self, the power of simplicity. Proceedings of OOPSLA, 1987.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. P. Wadler. The essence of functional programming. Proceedings POPL, 1992.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. A. Wright and M. Felleisen. A syntactic approach to type soundness. Information and Computation, 2004.]]Google ScholarGoogle Scholar
  54. H. Xi. Dependent Types in Practical Programming. PhD thesis, Carnegie Mellon University, 1998.]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. M. Zenger and M. Odersky. Independently extensible solutions to the expression problem. Workshop on Foundations of Object-Oriented Languages, 2005.]]Google ScholarGoogle Scholar
  56. J. Zwanenburg. Pure type systems with subtyping. International Conference on Typed Lambda Calculi and Applications, 1999.]] Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Eliminating distinctions of class: using prototypes to model virtual classes

        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

        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!