Skip to main content

Semantic Casts: Contracts and Structural Subtyping in a Nominal World

  • Conference paper
ECOOP 2004 – Object-Oriented Programming (ECOOP 2004)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 3086))

Included in the following conference series:

Abstract

Nominal subtyping forces programmers to explicitly state all of the subtyping relationships in the program. This limits component reuse, because programmers cannot anticipate all of the contexts in which a particular class might be used. In contrast, structural subtyping implicitly allows any type with appropriate structure to be used in a given context. Languagues with contracts exacerbate the problem. Since contracts are typically expressed as refinements of types, contracts in nominally typed languages introduce additional obstacles to reuse.

To overcome this problem we show how to extend a nominally typed language with semantic casts that introduce a limited form of structural subtyping. The new language must dynamically monitor contracts, as new subtyping relationships are exploited via semantic casts. In addition, it must also track the casts to properly assign blame in case interface contract are violated.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. America, P.: Designing an object-oriented programming language with behavioural subtyping. In: de Bakker, J.W., Rozenberg, G., de Roever, W.-P. (eds.) REX 1990. LNCS, vol. 489, pp. 60–90. Springer, Heidelberg (1991)

    Chapter  Google Scholar 

  2. Bartetzko, D., Fischer, C., Moller, M., Wehrheim, H.: Jass - Java with assertions. In: Workshop on Runtime Verification, 2001. Held in conjunction with the 13th Conference on Computer Aided Verification, CAV (2001)

    Google Scholar 

  3. Bruce, K.B., Fiech, A., Petersen, L.: Subtyping is not a good “match” for object-oriented languages. In: Proceedings of European Conference on Object-Oriented Programming, pp. 104–127 (1997)

    Google Scholar 

  4. Bruce, K.B., Schuett, A., van Gent, R.: PolyTOIL:Atype-safe polymorphic object-oriented language. In: Olthoff, W. (ed.) ECOOP 1995. LNCS, vol. 952, pp. 27–51. Springer, Heidelberg (1995)

    Google Scholar 

  5. 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)

    Google Scholar 

  6. Cheon, Y.: A runtime assertion checker for the Java Modelling Language. Technical Report 03-09, Iowa State University Computer Science Department (April 2003)

    Google Scholar 

  7. Detlefs, D.L., Rustan, K., Leino, M., Nelson, G., Saxe, J.B.: Extended static checking. Technical Report 158, Compaq SRC Research Report (1998)

    Google Scholar 

  8. Duncan, A., Hölzle, U.: Adding contracts to Java with handshake. Technical Report TRCS98-32, The University of California at Santa Barbara (December 1998)

    Google Scholar 

  9. Findler, R.B., Clements, J., Flanagan, C., Flatt, M., Krishnamurthi, S., Steckler, P., Felleisen, M.: DrScheme: A programming environment for Scheme. PLILP 1997 12(2), 159–182 (2002); Hartel, P.H., Kuchen, H. (eds.) PLILP 1997. LNCS, vol. 1292, pp. 369–388. Springer, Heidelberg (1997)

    Google Scholar 

  10. Findler, R.B., Felleisen, M.: Contract soundness for object-oriented languages. In: Object- Oriented Programming, Systems, Languages, and Applications (2001)

    Google Scholar 

  11. Findler, R.B., Felleisen, M.: Contracts for higher-order functions. In: Proceedings of ACM SIGPLAN International Conference on Functional Programming (2002)

    Google Scholar 

  12. Findler, R.B., Latendresse, M., Felleisen, M.: Behavioral contracts and behavioral subtyping. In: Proceedings of ACM Conference Foundations of Software Engineering (2001)

    Google Scholar 

  13. Fisher, K., Reppy, J.H.: The design of a class mechanism for Moby. In: Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation (1999)

    Google Scholar 

  14. Flanagan, C., Leino, K.R.M., Lillibridge, M., Nelson, G., Saxe, J.B., Stata, R.: Extended static checking for Java. In: Proceedings of ACM SIGPLAN Conference on Programming Language Design and Implementation, pp. 234–245 (2002)

    Google Scholar 

  15. Flatt, M.P.: MzScheme: Language manual. Technical Report TR97-280, Rice University (1997), http://www.mzscheme.org/

  16. Flatt, M., Krishnamurthi, S., Felleisen, M.: Classes and mixins. In: Proceedings of the ACM Conference Principles of Programming Languages, Janurary 1998, pp. 171–183 (1998)

    Google Scholar 

  17. Gomes, B., Stoutamire, D., Vaysman, B., Klawitter, H.: A Language Manual for Sather 1.1 (August 1996)

    Google Scholar 

  18. Gosling, J., Joy, B., Guy Steele, J.: The Java(tm) Language Specification. Addison-Wesley, Reading (1996)

    Google Scholar 

  19. Guttag, J.V., Horning, J.J.: Larch: Languages andTools forFormal Specification. Springer, Heidelberg (1993)

    Google Scholar 

  20. Henglein, F.: Dynamic typing: Syntax and proof theory. Science of Computer Programming 22(3), 197–230 (1994)

    Article  MATH  MathSciNet  Google Scholar 

  21. Holt, R.C., Cordy, J.R.: The Turing programming language. Communications of the ACM 31, 1310–1423 (1988)

    Article  Google Scholar 

  22. 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)

    Chapter  Google Scholar 

  23. Kizub, M.: Kiev language specification (1998), http://www.forestro.com/kiev/

  24. Kölling, M., Rosenberg, J.: Blue: Language Specification, version 0.94 (1997)

    Google Scholar 

  25. Kramer, R.: iContract: The Java design by contract tool. In: Technology of Object-Oriented Languages and Systems (1998)

    Google Scholar 

  26. Lampson, B.W., Horning, J.J., London, R.L., Mitchell, J.G., Popek, G.J.: Report on the programming language Euclid. ACM Sigplan Notices 12(2) (Feburary 1977)

    Google Scholar 

  27. Leavens, G.T., Leino, K.R.M., Poll, E., Ruby, C., Jacobs, B.: JML: notations and tools supporting detailed design in Java. In: Object-Oriented Programming, Systems, Languages, and Applications Companion, Also Department of Computer Science, Iowa State University, TR 00-15, August 2000, pp. 105–106 (2000)

    Google Scholar 

  28. Leroy, X.: Applicative functors and fully transparent higher-order modules. In: Proceedings of the ACM Conference Principles of Programming Languages, pp. 142–153. ACM Press, New York (1995)

    Google Scholar 

  29. Leroy, X.: The Objective Caml system, Documentation and User’s guide (1997)

    Google Scholar 

  30. Liskov, B.H., Wing, J.: Behavioral subtyping using invariants and constraints. Technical Report CMU CS-99-156, School of Computer Science, Carnegie Mellon University (July 1999)

    Google Scholar 

  31. Luckham, D.C., von Henke, F.: An overview of Anna, a specification language for Ada. IEEE Software 2, 9–23 (1985)

    Article  Google Scholar 

  32. Man Machine Systems. Design by contract for Java using JMSAssert (2000), http://www.mmsindia.com/DBCForJava.html

  33. Meyer, B.: Eiffel: The Language. Prentice Hall, Englewood Cliffs (1992)

    MATH  Google Scholar 

  34. Microsoft Corporation. Microsoft C# Language Specifications. Microsoft Press (2001)

    Google Scholar 

  35. Milner, R., Tofte, M., Harper, R.: The Definition of Standard ML. MIT Press, Cambridge (1990)

    Google Scholar 

  36. Object Management Group. The object management architecture guide (1997), http://www.omg.org/

  37. Parnas, D.L.: A technique for software module specification with examples. Communications of the ACM 15(5), 330–336 (1972)

    Article  Google Scholar 

  38. 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

  39. Plösch, R., Pichler, J.: Contracts: From analysis to C++ implementation. In: Technology of Object-Oriented Languages and Systems, pp. 248–257 (1999)

    Google Scholar 

  40. Rémy, D., Vouillon, J.: Objective ML: A simple object-oriented extension of ML. In: Proceedings of the ACM Conference Principles of Programming Languages, January 1997, pp. 40–53 (1997)

    Google Scholar 

  41. Rosenblum, D.S.: A practical approach to programming with assertions. IEEE Transactions on Software Engineering 21(1), 19–31 (1995)

    Article  Google Scholar 

  42. Sannella, D.: Formal program development in Extended ML for the working programmer. In: Proc. 3rd BCS/FACS Workshop on Refinement; Springer Workshops in Computing, pp. 99–130 (1991)

    Google Scholar 

  43. Sannella, D., Tarlecki, A.: Essential concepts of algebraic specification and program development. Formal Aspects of Computing 9, 229–269 (1997), http://www.dcs.ed.ac.uk/home/dts/eml/

    Article  MATH  Google Scholar 

  44. Scott, D.S.: Data types as lattices. Society of Industrial and Applied Mathematics (SIAM) Journal of Computing 5(3), 522–586 (1976)

    MATH  Google Scholar 

  45. Stroustrup, B.: The C++ Programming Language. Addison-Wesley, Reading (1997)

    Google Scholar 

  46. Szyperski, C.: Component Software, 2nd edn. Addison-Wesley, Reading (1998)

    Google Scholar 

  47. Wright, A., Felleisen, M.: A syntactic approach to type soundness. Information and Computation, pp. 38–94 (1994); First appeared as Technical Report TR160, Rice University (1991)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2004 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Findler, R.B., Flatt, M., Felleisen, M. (2004). Semantic Casts: Contracts and Structural Subtyping in a Nominal World. In: Odersky, M. (eds) ECOOP 2004 – Object-Oriented Programming. ECOOP 2004. Lecture Notes in Computer Science, vol 3086. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-24851-4_17

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-24851-4_17

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-22159-3

  • Online ISBN: 978-3-540-24851-4

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics