Abstract
Assertions play an important role in the construction of robust software. Their use in programming languages dates back to the 1970s. Eiffel, an object-oriented programming language, wholeheartedly adopted assertions and developed the "Design by Contract" philosophy. Indeed, the entire object-oriented community recognizes the value of assertion-based contracts on methods.
In contrast, languages with higher-order functions do not support assertion-based contracts. Because predicates on functions are, in general, undecidable, specifying such predicates appears to be meaningless. Instead, the functional languages community developed type systems that statically approximate interesting predicates.
In this paper, we show how to support higher-order function contracts in a theoretically well-founded and practically viable manner. Specifically, we introduce ?CON, a typed lambda calculus with assertions for higher-order functions. The calculus models the assertion monitoring system that we employ in Dr Scheme. We establish basic properties of the model (type soundness, etc.) and illustrate the usefulness of contract checking with examples from Dr Scheme's code base.
We believe that the development of an assertion system for higherorder functions serves two purposes. On one hand, the system has strong practical potential because existing type systems simply cannot express many assertions that programmers would like to state. nOn the other hand, an inspection of a large base of invariants may provide inspiration for the direction of practical future type system research.
- AT&T Bell Labratories. Standard ML of New Jersey, 1993.Google Scholar
- Clinger, W. D. Proper tail recursion and space efficiency. In Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 174--185, June 1998. Google ScholarDigital Library
- Felleisen, M., R. B. Findler, M. Flatt and S. Krishnamurthi. How to Design Programs. MIT Press, 2001.Google Scholar
- Felleisen, M. and R. Hieb. The revised report on the syntactic theories of sequential control and state. In Theoretical Computer Science, pages 235--271, 1992. Google ScholarDigital Library
- Findler, R. B., J. Clements, C. Flanagan, M. Flatt, S. Krishnamurthi, P. Steckler and M. Felleisen. DrScheme: A programming environment for Scheme. Journal of Functional Programming, 12(2):159--182, March 2002. A preliminary version of this paper appeared in PLILP 1997, LNCS volume 1292, pages 369--388. Google ScholarDigital Library
- Findler, R. B. and M. Felleisen. Contracts for higher-order functions. Technical Report NU-CCS-02-05, Northeastern University, 2002.Google ScholarDigital Library
- Findler, R. B. and M. Flatt. Modular object-oriented programming with units and mixins. In Proceedings of ACM SIGPLAN International Conference on Functional Programming, pages 94--104, September 1998. Google ScholarDigital Library
- Flatt, M. PLT MzScheme: Language manual. Technical Report TR97-280, Rice University, 1997. http://www.pltscheme. org/software/mzscheme/.Google Scholar
- Flatt, M. Composable and compilable macros: You want it when? In Proceedings of ACM SIGPLAN International Conference on Functional Programming, 2002. Google ScholarDigital Library
- Flatt, M., S. Krishnamurthi and M. Felleisen. A programmer's reduction semantics for classes and mixins. Formal Syntax and Semantics of Java, 1523:241--269, 1999. Preliminary version appeared in proceedings of Principles of Programming Languages, 1998. Revised version is Rice University technical report TR 97-293, June 1999. Google ScholarDigital Library
- Gomes, B., D. Stoutamire, B. Vaysman and H. Klawitter. A Language Manual for Sather 1.1, August 1996.Google Scholar
- Gosling, J., B. Joy and J. Guy Steele. The Java¿ Language Specification. Addison-Wesley, 1996. Google ScholarDigital Library
- Harper, R. and M. Lillibridge. A type-theoretic approach to higher-order modules with sharing. In Proceedings of ACM Conference Principles of Programming Languages, pages 123--137, Janurary 1994. Google ScholarDigital Library
- Holt, R. C. and J. R. Cordy. The Turing programming language. In Communications of the ACM, volume 31, pages 1310--1423, December 1988. Google ScholarDigital Library
- Jones, M. P., A. Reid and The Yale Haskell Group. The Hugs 98 User Manual, 1999.Google Scholar
- Kelsey, R., W. Clinger and J. R. (Editors). Revised5 report of the algorithmic language Scheme. ACM SIGPLAN Notices, 33(9):26--76, 1998. Google ScholarDigital Library
- Kölling, M. and J. Rosenberg. Blue: Language Specification, version 0.94, 1997.Google Scholar
- Leroy, X. Manifest types, modules, and separate compilation. In Proceedings of ACM Conference Principles of Programming Languages, pages 109--122, Janurary 1994. Google ScholarDigital Library
- Leroy, X. The Objective Caml system, Documentation and User's guide, 1997.Google Scholar
- Luckham, D. Programming with specifications. Texts and Monographs in Computer Science, 1990. Google ScholarDigital Library
- Luckham, D. C. and F. von Henke. An overview of Anna, a specification language for Ada. In IEEE Software, volume 2, pages 9--23, March 1985. Google ScholarDigital Library
- Meyer, B. Eiffel: The Language. Prentice Hall, 1992. Google ScholarDigital Library
- Milner, R., M. Tofte and R. Harper. The Definition of Standard ML. MIT Press, 1990. Google ScholarDigital Library
- Mitchell, J. C. and G. D. Plotkin. Abstract types have existential type. ACM Transactions on Programming Languages and Systems, 10(3):470--502, 1988. Google ScholarDigital Library
- Parnas, D. L. A technique for software module specification with examples. Communications of the ACM, 15(5):330--336, May 1972. Google ScholarDigital Library
- Rémy, D. and J. Vouillon. Objective ML: A simple objectoriented extension of ML. In Proceedings of ACM Conference Principles of Programming Languages, pages 40--53, January 1997. Google ScholarDigital Library
- Rosenblum, D. S. A practical approach to programming with assertions. IEEE Transactions on Software Engineering, 21(1):19--31, Janurary 1995. Google ScholarDigital Library
- Serrano, M. Bigloo: A practical Scheme compiler, 1992--2002.Google Scholar
- Serrano, M. Bee: an integrated development environment for the Scheme programming language. Journal of Functional Programming, 10(2):1--43, May 2000. Google ScholarDigital Library
- Steele, G. L. J. Debunking the "expensive procedure call" myth; or, Procedure call implementations considered harmful; or, LAMBDA: The ultimate goto. Technical Report 443, MIT Artificial Intelligence Laboratory, 1977. First appeared in the Proceedings of the ACM National Conference (Seattle, October 1977), 153--162. Google ScholarDigital Library
- Switzer, R. Eiffel: An Introduction. Prentice Hall, 1993. Google ScholarDigital Library
- Szyperski, C. Component Software. Addison-Wesley, 1998.Google Scholar
- The GHC Team. The Glasgow Haskell Compiler User's Guide, 1999.Google Scholar
- Wright, A. and M. Felleisen. A syntactic approach to type soundness. Information and Computation, pages 38--94, 1994. First appeared as Technical Report TR160, Rice University, 1991. Google ScholarDigital Library
Index Terms
- ICFP 2002: Contracts for higher-order functions
Recommendations
Contracts for higher-order functions
ICFP '02: Proceedings of the seventh ACM SIGPLAN international conference on Functional programmingAssertions play an important role in the construction of robust software. Their use in programming languages dates back to the 1970s. Eiffel, an object-oriented programming language, wholeheartedly adopted assertions and developed the "Design by ...
Contracts for higher-order functions
Assertions play an important role in the construction of robust software. Their use in programming languages dates back to the 1970s. Eiffel, an object-oriented programming language, wholeheartedly adopted assertions and developed the "Design by ...
Future contracts
PPDP '09: Proceedings of the 11th ACM SIGPLAN conference on Principles and practice of declarative programmingMany recent research projects focus on language support for behavioral software contracts, that is, assertions that govern the boundaries between software building blocks such as procedures, classes, or modules. Contracts primarily help locate bugs in ...
Comments