Abstract
Assertion-based contracts provide a powerful mechanism for stating invariants at module boundaries and for enforcing them uniformly. In 2002, Findler and Felleisen showed how to add contracts to higher-order functional languages, allowing programmers to assert invariants about functions as values. Following up in 2004, Blume and McAllester provided a quotient model for contracts. Roughly speaking, their model equates a contract with the set of values that cannot violate the contract. Their studies raised interesting questions about the nature of contracts and, in particular, the nature of the any contract.
In this paper, we develop a model for software contracts that follows Dana Scott’s program by interpreting contracts as projections. The model has already improved our implementation of contracts. We also demonstrate how it increases our understanding of contract-oriented programming and design. In particular, our work provides a definitive answer to the questions raised by Blume and McAllester’s work. The key insight from our model that resolves those questions is that a contract that puts no obligation on either party is not the same as the most permissive contract for just one of the parties.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Bartetzko, D.: Parallelität und Vererbung beim Programmieren mit Vertrag. Diplomarbeit, Universität Oldenburg (April 1999)
Blume, M., McAllester, D.: Sound and complete models of contracts. Journal of Functional Programming (to appear)
Carrillo-Castellon, M., Garcia-Molina, J., Pimentel, E., Repiso, I.: Design by contract in Smalltalk. Journal of Object-Oriented Programming 7(9), 23–28 (1996)
Cheon, Y.: A runtime assertion checker for the Java Modelling Language. Technical Report 03-09, Iowa State University Computer Science Department (April 2003)
Conway, D., Goebel, C.G.: Class:Contract – design-by-contract OO in Perl, http://search.cpan.org/~ggoebel/Class-Contract-1.14/
Danvy, O., Nielsen, L.R.: Defunctionalization at work. In: International Conference on Principles and Practice of Declarative Programming (2001)
Duncan, A., Hölzle, U.: Adding contracts to Java with handshake. Technical Report TRCS98-32, The University of California at Santa Barbara (December 1998)
Dybvig, R.K., Hieb, R., Bruggeman, C.: Syntactic abstraction in Scheme. Lisp and Symbolic Computation 5(4), 295–326 (1993)
Felleisen, M., Hieb, R.: The revised report on the syntactic theories of sequential control and state. Theoretical Computer Science, 235–271 (1992)
Findler, B., Blume, C., Felleisen, F., Huang, M., McCarthy, S., Press, R., Reppy, R., Spiro, T., Wick: The eighth annual ICFP programming contest, http://icfpc.plt-scheme.org/
Findler, R.B., Blume, M.: Contracts as pairs of projections. Technical Report TR- 2006-01, University of Chicago Computer Science Department (2006), http://www.cs.uchicago.edu/research/publications/techreports/TR-2006-01
Findler, R.B., Blume, M., Felleisen, M.: An investigation of contracts as projections. Technical Report TR-2004-02, University of Chicago Computer Science Department (2004)
Findler, R.B., Felleisen, M.: Contract soundness for object-oriented languages. In: Object-Oriented Programming, Systems, Languages, and Applications (2001)
Findler, R.B., Felleisen, M.: Contracts for higher-order functions. In: Proceedings of ACM SIGPLAN International Conference on Functional Programming (2002)
Findler, R.B., Flatt, M., Felleisen, M.: Semantic casts: Contracts and structural subtyping in a nominal world. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 365–389. Springer, Heidelberg (2004)
Findler, R.B., Latendresse, M., Felleisen, M.: Behavioral contracts and behavioral subtyping. In: Proceedings of ACM Conference Foundations of Software Engineering (2001)
Flatt, M.P.: Language manual. Technical Report TR97-280, Rice University (1997), http://www.mzscheme.org/
Gray, K.E., Findler, R.B., Flatt, M.: Fine-grained interoperability through contracts and mirrors. In: Object-Oriented Programming, Systems, Languages, and Applications (2005)
Jones, S.P., Washburn, G., Weirich, S.: Wobbly types: Practical type inference for generalized algebraic dataypes, http://www.cis.upenn.edu/~sweirich/publications.html
Karaorman, M., Hölzle, U., Bruno, J.: jContractor: A reflective java library to support design by contract. In: Cointe, P. (ed.) Reflection 1999. LNCS, vol. 1616, p. 175. Springer, Heidelberg (1999)
Kelsey, R., Clinger, W., Rees, J. (eds.): Revised5 report of the algorithmic language Scheme; Higher-Order and Symbolic Computation 11(1), 7–105 (1998); Also appears in ACM SIGPLAN Notices 33(9) (September 1998)
Kiniry, J.R., Cheong, E.: JPP: A Java pre-processor. Technical Report CS-TR-98-15, Department of Computer Science, California Institute of Technology (1998)
Kohlbecker, E.E., Friedman, D.P., Felleisen, M., Duba, B.F.: Hygienic macro expansion. In: ACM Symposium on Lisp and Functional Programming, pp. 151–161 (1986)
Kramer, R.: iContract: The Java design by contract tool. In: Technology of Object-Oriented Languages and Systems (1998)
Launchbury, J.: Projections factorizations in partial evaluation. Cambridge University Press, Cambridge (1991)
Man Machine Systems. Design by contract for Java using JMSAssert (2000), http://www.mmsindia.com/
Matthews, J., Findler, R.B.: An operational semantics for R5RS Scheme. In: Workshop on Scheme and Functional Programming (2005)
McCarthy, J.: A basis for a mathematical theory of computation. Computer Programming and Formal Systems (1961), http://www-formal.stanford.edu/jmc/basis/basis.html
McFarlane, K.: Design by contract framework, http://www.codeproject.com/csharp/designbycontract.asp
Meyer, B.E.: The Language. Prentice-Hall, Englewood Cliffs (1992)
Parnas, D.L.: A technique for software module specification with examples. Communications of the ACM 15(5), 330–336 (1972)
Plösch, R.: Design by contract for Python. In: IEEE Proceedings of the Joint Asia Pacific Software Engineering Conference (1997), http://citeseer.nj.nec.com/257710.html
Plösch, R., Pichler, J.: Contracts: From analysis to C++ implementation. In: Technology of Object-Oriented Languages and Systems, pp. 248–257 (1999)
Plotkin, G.D.: Call-by-name, call-by-value and the λ-calculus. Theoretical Computer Science 1, 125–159 (1975), http://homepages.inf.ed.ac.uk/gdp/publications/cbncbvlambda.pdf
PLT. PLT MzLib: Libraries manual. Technical Report PLT-TR05-4-v300, PLT Scheme Inc. (2005), http://www.plt-scheme.org/techreports/
Reynolds, J.C.: Definitional interpreters for higher-order programming languages. Higher- Order and Symbolic Computation 11(4), 363–397 (1998); Reprinted from the proceedings of the 25th ACM National Conference (1972), with a foreword
Rosenblum, D.S.: A practical approach to programming with assertions. IEEE Transactions on Software Engineering 21(1), 19–31 (1995)
Sabry, A., Felleisen, M.: Reasoning about programs in continuation-passing style. Lisp and Symbolic Computation 6(3/4), 289–360 (1993)
Scott, D.S.: Data types as lattices. Society of Industrial and Applied Mathematics (SIAM) Journal of Computing 5(3), 522–586 (1976)
The GHC Team. Glasgow Haskell compiler, http://www.haskell.org/ghc/
Wadler, P., Hughes, R.J.M.: Projections for Strictness Analysis. In: Kahn, G. (ed.) FPCA 1987. LNCS, vol. 274, pp. 385–407. Springer, Heidelberg (1987)
Xi, H., Chen, C., Chen, G.: Guarded recursive datatype constructors. In: Proceedings of the ACM Conference Principles of Programming Languages (2003)
Yang, Z.: Encoding types in ml-like languages. In: Proceedings of ACM SIGPLAN International Conference on Functional Programming (1998)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2006 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Findler, R.B., Blume, M. (2006). Contracts as Pairs of Projections. In: Hagiya, M., Wadler, P. (eds) Functional and Logic Programming. FLOPS 2006. Lecture Notes in Computer Science, vol 3945. Springer, Berlin, Heidelberg. https://doi.org/10.1007/11737414_16
Download citation
DOI: https://doi.org/10.1007/11737414_16
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-33438-5
Online ISBN: 978-3-540-33439-2
eBook Packages: Computer ScienceComputer Science (R0)