skip to main content
10.1145/1449764.1449800acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Constrained types for object-oriented languages

Published:19 October 2008Publication History

ABSTRACT

X10 is a modern object-oriented language designed for productivity and performance in concurrent and distributed systems. In this setting, dependent types offer significant opportunities for detecting design errors statically, documenting design decisions, eliminating costly run-time checks (e.g., for array bounds, null values), and improving the quality of generated code.

We present the design and implementation of constrained types, a natural, simple, clean, and expressive extension to object-oriented programming: A type C{c} names a class or interface C and a constraint c on the immutable state of C and in-scope final variables. Constraints may also be associated with class definitions (representing class invariants) and with method and constructor definitions (representing preconditions). Dynamic casting is permitted. The system is parametric on the underlying constraint system: the compiler supports a simple equality-based constraint system but, in addition, supports extension with new constraint systems using compiler plugins.

References

  1. Alexander Aiken, Edward L. Wimmers, and T. K. Lakshman. Soft typing with conditional types. In Proceedings of the 21st Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pages 163--173, January 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Hassan Ait-Kaci. A lattice theoretic approach to computation based on a calculus of partially ordered type structures (property inheritance, semantic nets, graph unification). PhD thesis, University of Pennsylvania, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Thorsten Altenkirch, Conor McBride, and James McKinna. Why dependent types matter. http://www.e-pig.org/downloads/ydtm.pdf, April 2005.Google ScholarGoogle Scholar
  4. Chris Andreae, James Noble, Shane Markstrum, and Todd Millstein. A framework for implementing pluggable type systems. In Proceedings of the 2006 ACM Conference on Object Oriented Programming Systems, Languages, and Applications (OOPSLA), October 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. David Aspinall and Martin Hofmann. Dependent Types, chapter 2. In Pierce {52}, 2004.Google ScholarGoogle Scholar
  6. Lennart Augustsson. Cayenne: a language with dependent types. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP '98), pages 239--250, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Clark Barrett and Sergey Berezin. CVC Lite: A new implementation of the cooperating validity checker. In Rajeev Alur and Doron A. Peled, editors, Proceedings of the $16^th$ International Conference on Computer Aided Verification (CAV '04), volume 3114 of Lecture Notes in Computer Science, pages 515--518. Springer-Verlag, July 2004. Boston, Massachusetts.Google ScholarGoogle Scholar
  8. Clark Barrett, Cesare Tinelli, Alexander Fuchs, Yeting Ge, George Hagen, and Dejan Jovanovic. CVC3. http://www.cs.nyu.edu/acsys/cvc3.Google ScholarGoogle Scholar
  9. Gilad Bracha. Pluggable type systems. In OOPSLA'04 Workshop on Revival of Dynamic Languages, October 2004.Google ScholarGoogle Scholar
  10. Bradford L. Chamberlain, Sung-Eun Choi, Steven J. Deitz, and Lawrence Snyder. The high-level parallel language ZPL improves productivity and performance. In Proceedings of the IEEE International Workshop on Productivity and Performance in High-End Computing, 2004.Google ScholarGoogle Scholar
  11. Craig Chambers. Predicate classes. In ECOOP '93 Conference Proceedings, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Brian Chin, Shane Markstrum, and Todd Millstein. Semantic type qualifiers. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 85--95, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Stephen Chong, Andrew C. Myers, K. Vikram, and Lantian Zheng. Jif reference manual, Jif 3.0.0 version. http://www.cs.cornell.edu/jif, June 2006.Google ScholarGoogle Scholar
  14. Dave Clarke, Sophia Drossopoulou, James Noble, and Tobias Wrigstad. Tribe: a simple virtual class calculus. In AOSD '07: Proceedings of the 6th international conference on Aspect-oriented software development, pages 121--134, New York, NY, USA, 2007. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. The Coq proof assistant: Reference manual, version 8.1. http://coq.inria.fr/, 2006.Google ScholarGoogle Scholar
  16. Thierry Coquand and Gerard Huet. The Calculus of Constructions. Information and Computation, 76, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Erik Ernst. gbeta: A Language with Virtual Attributes, Block Structure, and Propagating, Dynamic Inheritance. PhD thesis, Department of Computer Science, University of Aarhus, Århus, Denmark, 1999.Google ScholarGoogle Scholar
  18. Erik Ernst, Klaus Ostermann, and William R. Cook. A virtual class calculus. In Proc. 33th ACM Symp. on Principles of Programming Languages (POPL), pages 270--282, Charleston, South Carolina, January 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Cormac Flanagan. Hybrid type checking. In Proceedings of the 33rd Annual Symposium on Principles of Programming Languages (POPL'06), pages 245--256, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Cormac Flanagan, Stephen N. Freund, and Aaron Tomb. Hybrid types, invariants, and refinements for imperative objects. In International Workshop on Foundations of Object-Oriented Programming (FOOL), 2006.Google ScholarGoogle Scholar
  21. Cormac Flanagan, K. Rustan M. Leino, Mark Lillibridge, Greg Nelson, James B. Saxe, and Raymie Stata. Extended static checking for Java. In Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), June 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Seth Fogarty, Emir Pašalić, Jeremy Siek, and Walid Taha. Concoqtion: indexed types now! In Proceedings of the 2007 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-based Program Manipulation (PEPM), pages 112--121, January 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Jeffrey S. Foster, Tachio Terauchi, and Alex Aiken. Flow-sensitive type qualifiers. In Proc. 29th ACM Symp. on Principles of Programming Languages (POPL), pages 1--12. ACM Press, June 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Tim Freeman and Frank Pfenning. Refinement types for ML. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 268--277, June 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Vaidas Gasiunas, Mira Mezini, and Klaus Ostermann. Dependent classes. In OOPSLA '07: Proceedings of the 22nd annual ACM SIGPLAN Conference on Object-oriented Programming Systems, Languages, and Applications, pages 133--152. ACM, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. J. Gosling, W. Joy, G. Steele, and G. Bracha. The Java Language Specification, Third Edition. Addison Wesley, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Christian Grothoff, Jens Palsberg, and Vijay Saraswat. Safe arrays via regions and dependent types. Technical Report RC23911, IBM T.J. Watson Research Center, 2006.Google ScholarGoogle Scholar
  28. John Hughes, Lars Pareto, and Amr Sabry. Proving the correctness of reactive systems using sized types. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pages 410--423, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. A. Igarashi, B. Pierce, and P. Wadler. Featherweight Java: A minimal core calculus for Java and GJ. In ACM Symposium on Object-Oriented Programming: Systems, Languages and Applications, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. J. Jaffar and J.-L. Lassez. Constraint Logic Programming. In Proceedings of the 14th Annual ACM Symposium on Principles of Programming Languages (POPL'87), pages 111--119. ACM Press, New York (NY), USA, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Radha Jagadeesan, Gopalan Nadathur, and Vijay A. Saraswat. Testing concurrent systems: An interpretation of intuitionistic logic. In Ramaswamy Ramanujam and Sandeep Sen, editors, FSTTCS, volume 3821 of Lecture Notes in Computer Science, pages 517--528. Springer, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Mark P. Jones. Qualified Types: Theory and Practice. Cambridge University Press, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. JSR 308: Annotations on Java types. http://jcp.org/en/jsr/detail?id=308.Google ScholarGoogle Scholar
  34. Xavier Leroy et al. The Objective Caml system. http://caml.inria.fr/ocaml/.Google ScholarGoogle Scholar
  35. O. Lehrmann Madsen, B. Møller-Pedersen, and K. Nygaard. Object Oriented Programming in the BETA Programming Language. Addison-Wesley, June 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Ole Lehrmann Madsen and Birger Møller-Pedersen. Virtual classes: A powerful mechanism for object-oriented programming. In Proc. OOPSLA '89, pages 397--406, October 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Per Martin-Löf. A Theory of Types. 1971.Google ScholarGoogle Scholar
  38. Conor McBride and James McKinna. The view from the left. Journal of Functional Programming, 14(1):69--111, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Todd Millstein. Practical predicate dispatch. In Proceedings of the 19th ACM Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA), October 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. John C. Mitchell. Coercion and type inference. In Proceedings of the 11th Annual ACM Symposium on Principles of Programming Languages (POPL'84), pages 174--185, 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Andrew C. Myers. JFlow: Practical mostly-static information flow control. In Proc. 26th ACM Symp. on Principles of Programming Languages (POPL), pages 228--241, San Antonio, TX, January 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. G. Nelson and D. Oppen. Simplification by cooperating decision procedures. ACM Transactions on Programming Languages and Systems (TOPLAS), 1(2), October 1979. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. Flemming Nielson and Hanne Riis Nielson. Two-level functional languages. Cambridge University Press, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. Nathaniel Nystrom, Michael R. Clarkson, and Andrew C. Myers. Polyglot: An extensible compiler framework for Java. In Görel Hedin, editor, Compiler Construction, 12th International Conference, CC 2003, number 2622 in LNCS, pages 138--152. Springer-Verlag, April 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. Nathaniel Nystrom, Xin Qi, and Andrew C. Myers. J&: Nested intersection for scalable software extension. In Proceedings of the 2006 ACM Conference on Object Oriented Programming Systems, Languages, and Applications (OOPSLA '06), pages 21--36, Portland, OR, October 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. Nathaniel Nystrom and Vijay Saraswat. An annotation and compiler plugin system for X10. Technical Report RC24198, IBM T.J. Watson Research Center, 2007.Google ScholarGoogle Scholar
  47. Martin Odersky. Report on the programming language Scala. Technical report, EPFL, 2006.Google ScholarGoogle Scholar
  48. Martin Odersky, Philippe Altherr, Vincent Cremet, Burak Emir, Sebastian Maneth, Stéphane Micheloud, Nikolay Mihaylov, Michel Schinz, Erik Stenman, and Matthias Zenger. An overview of the Scala programming language, June 2004. http://scala.epfl.ch/docu/files/ScalaOverview.pdf.Google ScholarGoogle Scholar
  49. Martin Odersky, Vincent Cremet, Christine Röckl, and Matthias Zenger. A nominal theory of objects with dependent types. In Proceedings of 17th European Conference on Object-Oriented Programming (ECOOP 2003), number 2743 in Lecture Notes in Computer Science, pages 201--224. Springer-Verlag, July 2003.Google ScholarGoogle ScholarCross RefCross Ref
  50. Martin Odersky and Christoph Zenger. Nested types. In 8th Workshop on Foundations of Object-Oriented Languages (FOOL), 2001.Google ScholarGoogle Scholar
  51. Martin Odersky and Matthias Zenger. Scalable component abstractions. In Proc. OOPSLA '05, pages 41--57, San Diego, CA, USA, October 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. Benjamin C. Pierce, editor. Advanced Topics in Types and Programming Languages. MIT Press, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. François Pottier. Simplifying subtyping constraints. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP '96), pages 122--133, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. W. H. Press, B. P. Flannery, S. A. Teukolsky, and W. T. Vetterling. Numerical Recipes in FORTRAN: The Art of Scientific Computing, pages 866--869. Cambridge University Press, 1992. Successive overrelaxation (SOR). Google ScholarGoogle ScholarDigital LibraryDigital Library
  55. John C. Reynolds. Three approaches to type structure. In Proceedings of TAPSOFT/CAAP 1985, volume 185 of LNCS, pages 97--138. Springer-Verlag, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. Patrick Rondon, Ming Kawaguchi, and Ranjit Jhala. Liquid types. In Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), June 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  57. Vijay Saraswat. The category of constraint systems is Cartesian closed. In LICS '92, pages 341--345, 1992.Google ScholarGoogle ScholarCross RefCross Ref
  58. Vijay Saraswat et al. The X10 language specification. Technical report, IBM T.J. Watson Research Center, 2006.Google ScholarGoogle Scholar
  59. Martin Sulzmann, Martin Odersky, and Martin Wehr. Type inference with constrained types. In Fourth International Workshop on Foundations of Object-Oriented Programming (FOOL 4), 1997.Google ScholarGoogle Scholar
  60. Martin Sulzmann and Peter J. Stuckey. HM(X) type inference is CLP(X) solving. Journal of Functional Programming, 18(2):251--283, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  61. Walid Taha and Tim Sheard. Multi-stage programming with explicit annotations. In ACM/SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation, pages 203--217, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  62. Valery Trifonov and Scott Smith. Subtyping constrained types. In Third International Static Analysis Symposium (SAS), number 1145 in LNCS, pages 349--365, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  63. Hongwei Xi and Frank Pfenning. Eliminating array bound checking through dependent types. In Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), pages 249--257, Montreal, Canada, June 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  64. Hongwei Xi and Frank Pfenning. Dependent types in practical programming. In Proceedings of the 26th Annual ACM Symposium on Principles of Programming Languages (POPL'99), pages 214--227, San Antonio, TX, January 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Constrained types for object-oriented languages

        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!