skip to main content
research-article

Contracts for first-class classes

Published:18 October 2010Publication History
Skip Abstract Section

Abstract

First-class classes add expressive power to class-based object-oriented languages. Most importantly, programmers can abstract over common scenarios with first-class classes. When it comes to behavioral software contracts, however, first-class classes pose significant challenges. In this paper, we present the first contract system for a programming language with first-class classes. The design has been implemented for Racket, which supports first-class classes and which implements mixins and traits as syntactic sugar. We expect that our experience also applies to languages with native mixins and/or traits.

References

  1. }}Eric Allen, Jonathan Bannet, and Robert Cartwright. A first-class approach to genericity. In Object-Oriented Programming, Systems, Languages, and Applications, pages 96--114, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. }}Eric Allen, David Chase, Joe Hallett, Victor Luchangco, Jan-Willem Maessen, Sukyoung Ryu, Guy L. Steele Jr., and Sam Tobin-Hochstadt. The Fortress Language Specification Version 1.0. Sun Microsystems, 2008.Google ScholarGoogle Scholar
  3. }}Davide Ancona, Giovanni Lagorio, and Elena Zucca. Jam - designing a Java extension with mixins. ACM Trans. Program. Lang. Syst., 25(5):641--712, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. }}Mike Barnett, K. Rustan, M. Leino, and Wolfram Schulte. The Spec# programming system: An overview. In Construction and Analysis of Safe, Secure and Interoperable Smart devices, volume 3362 of LNCS, pages 49--69. Springer, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. }}Detlef Bartetzko, Clemens Fischer, Michael Moller, and Heike Wehrheim. Jass - Java with assertions. Electronic Notes in Theoretical Computer Science, 55(2):103--117, 2001.Google ScholarGoogle ScholarCross RefCross Ref
  6. }}Antoine Beugnard, Jean-Marc Jézéquel, Noël Plouzeau, and Damien Watkins. Making components contract aware. In IEEE Software, pages 38--45, June 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. }}Gilad Bracha and William Cook. Mixin-based inheritance. In Object-Oriented Programming, Systems, Languages, and Applications/European Conference on Object-Oriented Programming, pages 303--311, Ottawa, Canada, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. }}M. Carrillo-Castellon, J. Garcia-Molina, E. Pimentel, and I. Repiso. Design by contract in Smalltalk. Journal of Object-Oriented Programming, 7(9):23--28, 1996.Google ScholarGoogle Scholar
  9. }}Dominic Duggan and Ching-Ching Techaubol. Modular mixin-based inheritance for application frameworks. In Object-Oriented Programming, Systems, Languages, and Applications, pages 223--240, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. }}Erik Ernst. gbeta - a Language with Virtual Attributes, Block Structure, and Propagating, Dynamic Inheritance. PhD thesis, University of Aarhus, Århus, Denmark, 1999.Google ScholarGoogle Scholar
  11. }}Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, and Shriram Krishnamurthi. A functional I/O system, or fun for freshman kids. In International Conference on Functional Programming, pages 47--58, September 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. }}R. Findler and M. Felleisen. Contract soundness for object-oriented languages. In Object-Oriented Programming, Systems, Languages, and Applications, pages 1--15, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. }}Robert Bruce Findler and Matthias Blume. Contracts as pairs of projections. In Functional and Logic Programming, volume 3945 of LNCS, pages 226--241. Springer, April 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. }}Robert Bruce Findler, John Clements, Cormac Flanagan, Matthew Flatt, Shriram Krishnamurthi, Paul Steckler, and Matthias Felleisen. DrScheme: A programming environment for Scheme. Journal of Functional Programming, 12(2):159--182, March 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. }}Robert Bruce Findler and Matthias Felleisen. Contracts for higher-order functions. In International Conference on Functional Programming, pages 48--59, October 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. }}Matthew Flatt, Robert Bruce Findler, and Matthias Felleisen. Scheme with classes, mixins, and traits. In Asian Symposium on Programming Languages and Systems, pages 270--289, November 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. }}Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. Classes and mixins. In Symposium on Principles of Programming Languages, pages 171--183, January 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. }}Matthew Flatt and PLT. Reference: Racket. Technical Report PLT-TR2010-1, PLT Inc., June 7, 20http://racket-lang.org/tr1/.Google ScholarGoogle Scholar
  19. }}Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison Wesley, Massachusetts, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. }}Adele Goldberg and David Robinson. Smalltalk-80: The Language and its Implementation. Addison-Wesley, 1983. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. }}David S. Goldberg, Robert Bruce Findler, and Matthew Flatt. Super and inner - together at last! In Object-Oriented Programming, Systems, Languages, and Applications, pages 116--129, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. }}Benedict Gomes, David Stoutamire, Boris Vaysman, and Holger Klawitter. A Language Manual for Sather 1.1, August 1996.Google ScholarGoogle Scholar
  23. }}J. Gosling, B. Joy, and G. L.Steele. The Java Language Specification. Addison-Welsley, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. }}Murat Karaorman, Urs Hölzle, and John Bruno. jContractor: A reflective Java library to support design by contract. In Proceedings of Meta-Level Architectures and Reflection, volume 1616 of LNCS, pages 175--196, July 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. }}Casey Klein, Matthew Flatt, and Robert Bruce Findler. Random testing for higher-order, stateful programs. In Object-Oriented Programming, Systems, Languages, and Applications, 2010. To appear. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. }}Michael Kolling and John Rosenberg. Blue: Language Specification, version 0.94, 1997.Google ScholarGoogle Scholar
  27. }}Reto Kramer. iContract: The Java design by contract tool. In Technology of Object-Oriented Languages and Systems, page 295, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. }}John Lamping. Typing the specialization interface. In Object-Oriented Programming, Systems, Languages, and Applications, pages 201--214, September 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. }}B. W. Lampson, J. J. Horning, R. L. London, J. G. Mitchell, and G. J. Popek. Report on the programming language Euclid. SIGPLAN Not., 12(2):1--79, February 1977. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. }}Gary T. Leavens, Yoonsik Cheon, Curtis Clifton, Clyde Ruby, and David R. Cok. How the design of JML accommodates both runtime assertion checking and formal verification. Sci. Comput. Program., 55(1-3):185--208, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. }}Ole Lehrmann Madsen, Birger Møller-Pedersen, and Kristen Nygaard. Object-oriented programming in the BETA programming language. Addison-Wesley Publishing Co., New York, NY, USA, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. }}Xavier Leroy. The Objective Caml system, Documentation and User's guide, 1997.Google ScholarGoogle Scholar
  33. }}Barbara H. Liskov and Jeannette M. Wing. A behavioral notion of subtyping. ACM Transactions on Programming Languages and Systems, 16(6):1811--1841, November 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. }}D. C. Luckham and F.W. von Henke. An overview of Anna, a specification language for Ada. In IEEE Software, volume 2, pages 9--23, March 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. }}Sean McDirmid, Matthew Flatt, and Wilson Hsieh. Jiazzi: new-age components for old-fashioned Java. In Object-Oriented Programming, Systems, Languages, and Applications, pages 211--222, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. }}Bertrand Meyer. Object-oriented Software Construction. Prentice Hall, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. }}Bertrand Meyer. Applying design by contract. IEEE Computer, 25(10):40--51, October 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. }}Bertrand Meyer. Eiffel: The Language. Prentice Hall, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. }}David A. Moon. Object-oriented programming with flavors. In Object-Oriented Programming, Systems, Languages, and Applications, pages 1--8, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. }}Martin Odersky. The Scala Language Specification. Ecole Polytechnique Fédérale de Lausanne, 2009.Google ScholarGoogle Scholar
  41. }}David L. Parnas. On the criteria to be used in decomposing systems into modules.Communications of the ACM, 15:1053--1058, 1972. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. }}R. Plösch. Design by contract for Python. In IEEE Proceedings of the Joint Asia Pacific Software Engineering Conference, pages 213--219, December 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  43. }}Didier Rémy and Jérôme Vouillon. Objective ML: A simple object-oriented extension of ML. In Symposium on Principles of Programming Languages, pages 40--53, January 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. }}Nathanael Schärli, Stéphane Ducasse, Oscar Nierstrasz, and Andrew Black. Traits: Composable units of behavior. In European Conference on Object-Oriented Programming, volume 2743 of LNCS, pages 248--274. Springer, July 2003.Google ScholarGoogle Scholar
  45. }}Michael Sperber, R. Kent Dybvig, Matthew Flatt, Anton Van Straaten, Robby Findler, and Jacob Matthews. Revised6 report on the algorithmic language Scheme. Journal of Functional Programming, 19(Supplement S1):1--301, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  46. }}T. Stephen Strickland and Matthias Felleisen. Contracts for first-class modules. In Symposium on Dynamic Languages, pages 27--38, October 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  47. }}T. Stephen Strickland and Matthias Felleisen. Nested and dynamic contract boundaries. In Implementation and Application of Functional Languages, September 2009. To appear. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. }}T. Stephen Strickland and Matthias Felleisen. Contracts for first-class classes. Technical Report NU-CCIS-10-04, Northeastern University, 2010.Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. }}Clemens Szyperski. Component Software. Addison-Wesley, 1997.Google ScholarGoogle Scholar

Index Terms

  1. Contracts for first-class 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

          Full Access

          • Published in

            cover image ACM SIGPLAN Notices
            ACM SIGPLAN Notices  Volume 45, Issue 12
            DLS '10
            December 2010
            107 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/1899661
            Issue’s Table of Contents
            • cover image ACM Conferences
              DLS '10: Proceedings of the 6th symposium on Dynamic languages
              October 2010
              120 pages
              ISBN:9781450304054
              DOI:10.1145/1869631

            Copyright © 2010 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 18 October 2010

            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!