Abstract

Static and dynamic type systems have well-known strengths and weaknesses. In previous work we developed a gradual type system for a functional calculus named \(\lambda^?_\to\). Gradual typing provides the benefits of both static and dynamic checking in a single language by allowing the programmer to control whether a portion of the program is type checked at compile-time or run-time by adding or removing type annotations on variables. Several object-oriented scripting languages are preparing to add static checking. To support that work this paper develops \(\mathbf{Ob}^{?}_{<:}\), a gradual type system for object-based languages, extending the Ob < : calculus of Abadi and Cardelli. Our primary contribution is to show that gradual typing and subtyping are orthogonal and can be combined in a principled fashion. We also develop a small-step semantics, provide a machine-checked proof of type safety, and improve the space efficiency of higher-order casts.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Abadi, M., Cardelli, L.: A Theory of Objects. Springer-Verlag, New York (1996)MATHGoogle Scholar
  2. 2.
    Abadi, M., Cardelli, L., Pierce, B., Plotkin, G.: Dynamic typing in a statically typed language. ACM Transactions on Programming Languages and Systems 13(2), 237–268 (1991)CrossRefGoogle Scholar
  3. 3.
    Aiken, A., Wimmers, E.L., Lakshman, T.K.: Soft typing with conditional types. In: POPL ’94: Proceedings of the 21st ACM SIGPLAN-SIGACT symposium on Principles of programming languages, Portland, Oregon, United States, pp. 163–173. ACM Press, New York (1994)CrossRefGoogle Scholar
  4. 4.
    Anderson, C., Drossopoulou, S.: BabyJ - from object based to class based programming via types. In: WOOD ’03, vol, vol. 82, Elsevier, Amsterdam (2003)Google Scholar
  5. 5.
    Aydemir, B.E., Bohannon, A., Fairbairn, M., Foster, J.N., Pierce, B.C., Sewell, P., Vytiniotis, D., Weirich, G.W.S., Zdancewic, S.: Mechanized metatheory for the masses: The POPLmark challenge (May 2005)Google Scholar
  6. 6.
    Bracha, G.: Pluggable type systems. In: OOPSLA’04 Workshop on Revival of Dynamic Languages (2004)Google Scholar
  7. 7.
    Bracha, G., Griswold, D.: Strongtalk: typechecking smalltalk in a production environment. In: OOPSLA ’93: Proceedings of the eighth annual conference on Object-oriented programming systems, languages, and applications, pp. 215–230. ACM Press, New York (1993)CrossRefGoogle Scholar
  8. 8.
    Bres, Y., Serpette, B.P., Serrano, M.: Compiling scheme programs to.NET common intermediate language. In: 2nd International Workshop on.NET Technologies, Pilzen, Czech Republic (May 2004)Google Scholar
  9. 9.
    Cartwright, R., Fagan, M.: Soft typing. In: PLDI ’91: Proceedings of the ACM SIGPLAN 1991 conference on Programming language design and implementation, pp. 278–292. ACM Press, New York (1991)CrossRefGoogle Scholar
  10. 10.
    Chambers, C., the Cecil Group.: The Cecil language: Specification and rationale. Technical report, Department of Computer Science and Engineering, University of Washington, Seattle, Washington (2004)Google Scholar
  11. 11.
    Chambers, C., Ungar, D., Lee, E.: An efficient implementation of self a dynamically-typed object-oriented language based on prototypes. In: OOPSLA ’89: Conference proceedings on Object-oriented programming systems, languages and applications, pp. 49–70. ACM Press, New York (1989)CrossRefGoogle Scholar
  12. 12.
    Damas, L., Milner, R.: Principal type-schemes for functional programs. In: POPL ’82: Proceedings of the 9th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pp. 207–212. ACM Press, New York (1982)CrossRefGoogle Scholar
  13. 13.
    de Oliveira, R.B.: The Boo programming language (2005), http://boo.codehaus.org
  14. 14.
    Dean, J., Chambers, C., Grove, D.: Selective specialization for object-oriented languages. In: PLDI ’95: Proceedings of the ACM SIGPLAN 1995 conference on Programming language design and implementation, La Jolla, California, United States, pp. 93–102. ACM Press, New York (1995)CrossRefGoogle Scholar
  15. 15.
    ECMA Standard ECMA-262: ECMAScript Language Specification (1999)Google Scholar
  16. 16.
    Feinberg, N., Keene, S.E., Mathews, R.O., Withington, P.T.: Dylan programming: an object-oriented and dynamic language. Addison Wesley Longman Publishing, Redwood City, CA (1997)MATHGoogle Scholar
  17. 17.
    Felleisen, M., Friedman, D.P.: Control operators, the SECD-machine and the lambda-calculus. pp. 193–217 (1986)Google Scholar
  18. 18.
    Felleisen, M., Hieb, R.: The revised report on the syntactic theories of sequential control and state. Theoretical Computer Science 103(2), 235–271 (1992)MATHCrossRefMathSciNetGoogle Scholar
  19. 19.
    Findler, R.B., Felleisen, M.: Contracts for higher-order functions. In: ACM International Conference on Functional Programming, ACM Press, New York (2002)Google Scholar
  20. 20.
    Findler, R.B., Flatt, M., Felleisen, M.: Semantic casts: Contracts and structural subtyping in a nominal world. In: European Conference on Object-Oriented Programming (2004)Google Scholar
  21. 21.
    Flanagan, C.: Hybrid type checking. In: POPL 2006: The 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, Charleston, South Carolina, pp. 245–256. ACM Press, New York (2006)CrossRefGoogle Scholar
  22. 22.
    Flanagan, C., Felleisen, M.: Componential set-based analysis. ACM Trans. Program. Lang. Syst. 21(2), 370–416 (1999)CrossRefGoogle Scholar
  23. 23.
    Flanagan, C., Flatt, M., Krishnamurthi, S., Weirich, S., Felleisen, M.: Catching bugs in the web of program invariants. In: PLDI ’96: Proceedings of the ACM SIGPLAN 1996 conference on Programming language design and implementation, Philadelphia, Pennsylvania, United States, pp. 23–32. ACM Press, New York (1996)CrossRefGoogle Scholar
  24. 24.
    Flanagan, C., Freund, S.N., Tomb, A.: Hybrid types, invariants, and refinements for imperative objects. In: FOOL/WOOD ’06: International Workshop on Foundations and Developments of Object-Oriented Languages (2006)Google Scholar
  25. 25.
    Gray, K.E., Findler, R.B., Flatt, M.: Fine-grained interoperability through mirrors and contracts. In: OOPSLA ’05: Proceedings of the 20th annual ACM SIGPLAN conference on Object oriented programming systems languages and applications, pp. 231–245. ACM Press, New York, NY, USA (2005)CrossRefGoogle Scholar
  26. 26.
    Gronski, J., Knowles, K., Tomb, A., Freund, S.N., Flanagan, C.: Sage: Hybrid checking for flexible specifications. Technical report, University of California, Santa Cruz (2006)Google Scholar
  27. 27.
    Group, E.T.W.: Ecmascript 4 netscape proposalGoogle Scholar
  28. 28.
    Gunter, C.A., Remy, D., Riecke, J.G.: A generalization of exceptions and control in ml-like languages. In: FPCA ’95: Proceedings of the seventh international conference on Functional programming languages and computer architecture, La Jolla, California, United States, pp. 12–23. ACM Press, New York (1995)CrossRefGoogle Scholar
  29. 29.
    Henglein, F.: Dynamic typing: syntax and proof theory. Science of Computer Programming 22(3), 197–230 (1994)MATHCrossRefMathSciNetGoogle Scholar
  30. 30.
    Henglein, F., Rehof, J.: Safe polymorphic type inference for a dynamically typed language: Translating scheme to ml. In: FPCA ’95, ACM SIGPLAN-SIGARCH Conference on Functional Programming Languages and Computer Architecture, La Jolla, California (June 1995)Google Scholar
  31. 31.
    Herman, D., Tomb, A., Flanagan, C.: Space-efficient gradual typing. In: Trends in Functional Programming (TFP), April 2007 (2007)Google Scholar
  32. 32.
    Hindley, R.: The principal type-scheme of an object in combinatory logic. Trans AMS 146, 29–60 (1969)MATHCrossRefMathSciNetGoogle Scholar
  33. 33.
    Steele Jr., G.L.: An overview of COMMON LISP. In: LFP ’82: Proceedings of the, ACM symposium on LISP and functional programming, pp. 98–107. ACM Press, New York (1982)CrossRefGoogle Scholar
  34. 34.
    Kelsey, R., Clinger, W., Rees, J. (eds.): Revised5 report on the algorithmic language scheme. Higher-Order and Symbolic Computation, 11(1) (August 1998)Google Scholar
  35. 35.
    Matthews, J., Findler, R.B.: Operational semantics for multi-language programs. In: The 34th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, January 2007, ACM Press, New York (2007)Google Scholar
  36. 36.
    Meijer, E., Drayton, P.: Static typing where possible, dynamic typing when needed: The end of the cold war between programming languages. In: OOPSLA’04 Workshop on Revival of Dynamic Languages (2004)Google Scholar
  37. 37.
    Milner, R.: A theory of type polymorphism in programming. Journal of Computer and System Sciences 17(3), 348–375 (1978)MATHCrossRefMathSciNetGoogle Scholar
  38. 38.
    Nanevski, A.: A modal calculus for exception handling. In: Intuitionistic Modal Logics and Applications Workshop (IMLA ’05), Chicago, IL, June 2005 (2005)Google Scholar
  39. 39.
    Nipkow, T., Paulson, L.C., Wenzel, M. (eds.): Isabelle/HOL. LNCS, vol. 2283. Springer, Heidelberg (2002)MATHGoogle Scholar
  40. 40.
    Ou, X., Tan, G., Mandelbaum, Y., Walker, D.: Dynamic typing with dependent types (extended abstract). In: 3rd IFIP International Conference on Theoretical Computer Science (August 2004)Google Scholar
  41. 41.
    Pierce, B.C.: Types and programming languages. MIT Press, Cambridge, MA, USA (2002)Google Scholar
  42. 42.
    Riely, J., Hennessy, M.: Trust and partial typing in open systems of mobile agents. In: POPL ’99: Proceedings of the 26th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pp. 93–104. ACM Press, New York (1999)CrossRefGoogle Scholar
  43. 43.
    Sabry, A.: Minml: Syntax, static semantics, dynamic semantics, and type safety. Course notes for b522 (February 2002)Google Scholar
  44. 44.
    Serrano, M.: Bigloo: a practical Scheme compiler. Inria-Rocquencourt (April 2002)Google Scholar
  45. 45.
    Shalit, A.: The Dylan reference manual: the definitive guide to the new object-oriented dynamic language. Addison Wesley Longman Publishing Co. Inc., Redwood City, CA (1996)MATHGoogle Scholar
  46. 46.
    Siek, J., Taha, W.: Gradual typing for objects: Isabelle formaliztaion. Technical Report CU-CS-1021-06, University of Colorado, Boulder, CO (December 2006)Google Scholar
  47. 47.
    Siek, J.G., Taha, W.: Gradual typing for functional languages. In: Scheme and Functional Programming Workshop (September 2006)Google Scholar
  48. 48.
    Taha, W., Makholm, H., Hughes, J.: Tag elimination and jones-optimality. In: Danvy, O., Filinski, A. (eds.) PADO 2001. LNCS, vol. 2053, pp. 257–275. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  49. 49.
    Tang, A.: Pugs blogGoogle Scholar
  50. 50.
    Thatte, S.: Quasi-static typing. In: POPL ’90: Proceedings of the 17th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pp. 367–381. ACM Press, New York (1990)CrossRefGoogle Scholar
  51. 51.
    Tobin-Hochstadt, S., Felleisen, M.: Interlanguage migration: From scripts to programs. In: Dynamic Languages Symposium (2006)Google Scholar
  52. 52.
    Wenzel, M.: The Isabelle/Isar Reference Manual. TU München (April 2004)Google Scholar
  53. 53.
    Wright, A.K., Felleisen, M.: A syntactic approach to type soundness. Information and Computation 115(1), 38–94 (1994)MATHCrossRefMathSciNetGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2007

Authors and Affiliations

  • Jeremy Siek
    • 1
  • Walid Taha
    • 2
  1. 1.University of Colorado, Boulder, CO 80309, USA, and LogicBlox Inc., Atlanta, GA 30309USA
  2. 2.Rice University, Houston, TX 77005USA

Personalised recommendations