Abstract
First-class classes enable programmers to abstract over patterns in the class hierarchy and to experiment with new forms of object-oriented programming such as mixins and traits. This increase in expressive power calls for tools to control the complexity of the software architecture. A contract system is one possible tool that has seen much use in object-oriented programming languages, but existing contract systems cannot cope with first-class classes. On the one hand, the typical contract language deals only with plain values such as numbers, while classes are higher-order values. On the other hand, contract specifications are usually contained within class definitions, while classes as values call for a separate contract language.
This article presents the design and implementation of a contract system for first-class classes as well as a two-pronged evaluation. The first one states and proves a “blame correctness” theorem for a model of our language. The theorem shows that when the contract system assigns blame to a component for a contract violation, the component is indeed responsible for providing the nonconforming value. The second part, consisting of benchmarks and case studies, demonstrates the need for the rich contract language and validates that our implementation approach is performant with respect to time.
- Eric Allen, Jonathan Bannet, and Robert Cartwright. 2003. A first-class approach to genericity. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’03). 96--114. Google Scholar
Digital Library
- Eric Allen, David Chase, Joe Hallett, Victor Luchangco, Jan-Willem Maessen, Sukyoung Ryu, Guy L. Steele Jr., and Sam Tobin-Hochstadt. 2008. The Fortress Language Specification Version 1.0. Sun Microsystems.Google Scholar
- Davide Ancona, Giovanni Lagorio, and Elena Zucca. 2003. Jam---Designing a Java extension with mixins. ACM Trans. Program. Lang. Syst. 25, 5, 641--712. Google Scholar
Digital Library
- Thomas H. Austin, Tim Disney, and Cormac Flanagan. 2010. Virtual values for language extension. Tech. rep. UCSC-SOE-10-25. University of California, Santa Cruz.Google Scholar
- Mike Barnett, K. Rustan M. Leino, and Wolfram Schulte. 2004. The spec# programming system: An overview. In Proceedings of the International Conference on Construction and Analysis of Safe, Secure and Interoperable Smart Devices (CASSIS’04). Lecture Notes in Computer Science, vol. 3362, Springer, 49--69. Google Scholar
Digital Library
- Detlef Bartetzko, Clemens Fischer, Michael Moller, and Heikewehrheim. 2001. Jass---Java with assertions. Electron. Not. Theor. Comput. Sci. 55, 2, 103--117.Google Scholar
Cross Ref
- Gilad Bracha. 1992. The programming language jigsaw: Mixins, modularity, and multiple inheritance. Ph.D. dissertation. University of Utah. http://www.cs.utah.edu/dept/techreports/docs/ncstrl.utah_cs/UUCS-92-007/UUCS-92-007.pdf. Google Scholar
Digital Library
- Gilad Bracha and William Cook. 1990. Mixin-based inheritance. In Proceedings of the European Conference on Object-Oriented Programming and the Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA/ECOOP’90). 303--311. Google Scholar
Digital Library
- Gilad Bracha and David Ungar. 2004. Mirrors: Design principles for meta-level facilities of object-oriented programming languages. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’04). 331--344. Google Scholar
Digital Library
- Luca Cardelli and John C. Mitchell. 1991. Operations on records. Math. Struct. Comput. Sci. 1, 3--48.Google Scholar
Cross Ref
- Manuela Carrillo-Castellon, Jesus Garcia-Molina, Ernesto Pimentel, and Israel Repiso. 1996. Design by contract in smalltalk. J. Object-Oriented Program. 7, 9, 23--28.Google Scholar
- Christos Dimoulas and Matthias Felleisen. 2011. On contract satisfaction in a higher-order world. ACM Trans. Program. Lang. Syst. 33, 5, 16:1--16:29. Google Scholar
Digital Library
- Christos Dimoulas, Robert B. Findler, Cormac Flanagan, and Matthias Felleisen. 2011. Correct blame for contracts: No more scapegoating. In Proceedings of the Symposium on Principles of Programming Languages. 215--226. Google Scholar
Digital Library
- Dominic Duggan and Ching-Ching Techaubol. 2001. Modular mixin-based inheritance for application frameworks. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’01). 223--240. Google Scholar
Digital Library
- Erik Ernst. 1999. gbeta---A language with virtual attributes, block structure, and propagating, dynamic inheritance. Ph.D. dissertation. University of Aarhus, Arhus, Denmark. http://ojs.statsbiblioteket.dk/index.php/daimipb/article/download/7654/6510.Google Scholar
- Matthias Felleisen. 1991. On the expressive power of programming languages. Sci. Comput. Program. 17, 1--3, 35--75. Google Scholar
Digital Library
- Matthias Felleisen, Robert Bruce Findler, and Matthew Flatt. 2009. Semantics Engineering with PLT Redex. MIT Press. Google Scholar
Digital Library
- Robert Bruce Findler and Matthias Blume. 2006. Contracts as pairs of projections. In Proceedings of the International Symposium on Functional and Logic Programming (FLOPS’06). Lecture Notes in Computer Science, vol. 3945, Springer, 226--241. Google Scholar
Digital Library
- Robert Bruce Findler, John Clements, Cormac Flanagan, Matthew Flatt, Shriram Krishnamurthi, Paul Steckler, and Matthias Felleisen. 2002. DrScheme: A programming environment for scheme. J. Funct. Program. 12, 2, 159--182. Google Scholar
Digital Library
- Robert Bruce Findler and Matthias Felleisen. 2001. Contract soundness for object-oriented languages. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’01). 1--15. Google Scholar
Digital Library
- Robert Bruce Findler and Matthias Felleisen. 2002. Contracts for higher-order functions. In Proceedings of the International Conference on Functional Programming. 48--59. Google Scholar
Digital Library
- Kathleen Fisher and John Reppy. 2004. A typed calculus of traits. In Proceedings of the Workshop on Foundations of Object-Oriented Languages.Google Scholar
- David Flanagan and Yukihiro Matsumoto. 2008. The Ruby Programming Language. O’Reilly. Google Scholar
Digital Library
- Matthew Flatt and PLT. 2010. Reference: Racket. Tech. rep. PLT-TR-2010-1. PLT Inc. http://racket-lang.org/tr1/.Google Scholar
- Matthew Flatt, Shriram Krishnamurthi, and Matthias Felleisen. 1998. Classes and mixins. In Proceedings of the Symposium on Principles of Programming Languages. 171--183. Google Scholar
Digital Library
- Matthew Flatt, Robert Bruce Findler, and Matthias Felleisen. 2006. Scheme with classes, mixins, and traits. In Proceedings of the Asian Symposium on Programming Languages and Systems. Lecture Notes in Computer Science, vol. 4279, Springer, 270--289. Google Scholar
Digital Library
- Benedict R. Gaster and Mark P. Jones. 1996. A polymorphic type system for extensible records and variants. Tech. rep. NOTTCS-TR-96-3. University of Nottingham.Google Scholar
- Adele Goldberg and David Robinson. 1983. Smalltalk-80: The Language and its Implementation. Addison-Wesley. Google Scholar
Digital Library
- David S. Goldberg, Robert Bruce Findler, and Matthew Flatt. 2004. Super and inner---Together at last! In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’04). 116--129. Google Scholar
Digital Library
- Benedict Gomes, David Stoutamire, Boris Vaysman, and Holger Klawitter. 1996. A language manual for sather 1.1. http://www1.icsi.berkeley.edu/_sather/Documentation/LanguageDescription/Descript.pdf.gz.Google Scholar
- Kathryn E. Gray. 2008. Safe cross-language inheritance. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP’08). Lecture Notes in Computer Science, vol. 5142, Springer, 52--75. Google Scholar
Digital Library
- Kathryn E. Gray. 2010. Interoperability in a scripted world: Putting inheritance and prototypes together. In Proceedings of the Workshop on Foundations of Object-Oriented Languages.Google Scholar
- Kathryn E. Gray, Robert Bruce Findler, and Matthew Flatt. 2005. Fine-grained interoperability through contracts and mirrors. In Proceedings of the ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’04). 231--245. Google Scholar
Digital Library
- Robert Harper and Benjamin Pierce. 1991. A records calculus based on symmetric concatenation. In Proceedings of the Symposium on Principles of Programming Languages. 131--142. Google Scholar
Digital Library
- Murat Karaorman, Urs Holzle, and John Bruno. 1999. jContractor: A reflective java library to support design by contract. In Proceedings of the International Conference on Meta-Level Architectures and Reflection (Reflection’99). Lecture Notes in Computer Science, vol. 1616, Springer, 175--196. Google Scholar
Digital Library
- Michael Kolling and John Rosenberg. 1997. Blue: Language specification, version 0.94. http://www.sd.monash.edu.au/blue/.Google Scholar
- Reto Kramer. 1998. iContract: The java design by contract tool. In Proceedings of the Conference on Technology of Object-Oriented Languages and Systems. 295. Google Scholar
Digital Library
- John Lamping. 1993. Typing the specialization interface. In Proceedings of the Annual Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’93). 201--214. Google Scholar
Digital Library
- Butler W. Lampson, James J. Horning, Ralph L. London, James G. Mitchell, and Gerald J. Popek. 1977. Report on the programming language euclid. SIGPLAN Not. 12, 2, 1--79. Google Scholar
Digital Library
- Gary T. Leavens. 2006. JML’s rich, inherited specifications for behavioral subtypes. In Proceedings of the International Conference on Formal Engineering Methods (ICFEM’06). Lecture Notes in Computer Science, vol. 4260, Springer, 2--34. Google Scholar
Digital Library
- Gary T. Leavens, Yoonsik Cheon, Curtis Clifton, Clyde Ruby, and David R. Cok. 2005. How the design of jml accommodates both runtime assertion checking and formal verification. Sci. Comput. Program. 55, 1--3, 185--208. Google Scholar
Digital Library
- Ole Lehrmann Madsen, Birger Møller-Pedersen, and Kristen Nygaard. 1993. Object-Oriented Programming in the BETA Programming Language. Addison-Wesley Publishing, New York. Google Scholar
Digital Library
- Barbara H. Liskov and Jeannette M. Wing. 1994. A behavioral notion of subtyping. ACM Trans. Program. Lang. Syst. 16, 6, 1811--1841. Google Scholar
Digital Library
- David C. Luckham and Friedrich W. Von Henke. 1985. An overview of anna, a specification language for ada. IEEE Softw. 2, 9--23. Google Scholar
Digital Library
- Sean Mcdirmid, Matthew Flatt, and Wilson Hsieh. 2001. Jiazzi: New-age components for old-fashioned java. In Proceedings of the Annual Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’01). 211--222. Google Scholar
Digital Library
- Bertrand Meyer. 1992a. Applying design by contract. IEEE Comput. 25, 10, 0--51. Google Scholar
Digital Library
- Bertrand Meyer. 1992b. Eiffel: The Language. Prentice Hall. Google Scholar
Digital Library
- David A. Moon. 1986. Object-oriented programming with flavors. In Proceedings of the Annual Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’86). 1--8. Google Scholar
Digital Library
- David L. Parnas. 1972. On the criteria to be used in decomposing systems into modules. Comm. ACM 15, 12, 1053--1058. Google Scholar
Digital Library
- Reinhold Plosch. 1997. Design by contract for python. In Proceedings of the IEEE Joint Asia Pacific Software Engineering Conference. 213--219. Google Scholar
Digital Library
- Gordon D. Plotkin. 1977. LCF considered as a programming language. Theor. Comput. Sci. 5, 223--255.Google Scholar
Cross Ref
- Nathanael Scharli, Stephane Ducasse, Oscar Nierstrasz, and Andrew Black. 2003. Traits: Composable units of behavior. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP’03). Lecture Notes in Computer Science, vol. 2743, Springer, 248--274.Google Scholar
Cross Ref
- Marco Servetto and Elena Zucca. 2010. MetaFJig: A meta-circular composition language for java-like classes. In Proceedings of the Annual Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’10). 464--483. Google Scholar
Digital Library
- T. Stephen Strickland and Matthias Felleisen. 2010a. Contracts for first-class classes. In Proceedings of the Dynamic Languages Symposium. 97--111. Google Scholar
Digital Library
- T. Stephen Strickland and Matthias Felleisen. 2010b. Nested and dynamic contract boundaries. In Proceedings of the International Conference on Implementation and Application of Functional Languages (IFL’10). Lecture Notes in Computer Science, vol. 6041, Springer, 141--158. Google Scholar
Digital Library
- T. Stephen Strickland, Sam Tobin-Hochstadt, Robert Bruce Findler, and Matthew Flatt. 2012. Chaperones and impersonators: Run-time support for reasonable interposition. In Proceedings of the Annual Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA’12). 943--962. Google Scholar
Digital Library
- Clemens Szyperski. 1997. Component Software. Addison-Wesley.Google Scholar
- Tom Van Cutsem and Mark Miller. 2010. Proxies: Design principles for robust object-oriented intercession apis. In Proceedings of the Dynamic Languages Symposium. 59--72. Google Scholar
Digital Library
- Mitchell Wand. 1994. Type inference for objects with instance variables and inheritance. In Theoretical Aspects of Object-Oriented Programming. MIT Press, 97--120. Google Scholar
Digital Library
Index Terms
Contracts for First-Class Classes
Recommendations
Contracts for first-class classes
DLS '10: Proceedings of the 6th symposium on Dynamic languagesFirst-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 ...
Contracts for first-class classes
DLS '10First-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 ...
Contracts for first-class modules
DLS '09: Proceedings of the 5th symposium on Dynamic languagesBehavioral software contracts express properties concerning the flow of values across component (modules, classes, etc) interfaces. These properties are often beyond the reach of theorem provers and are therefore monitored at run-time. When the monitor ...








Comments