Abstract
Gradual type systems offer a smooth continuum between static and dynamic typing by permitting the free mixture of typed and untyped code. The runtime systems for these languages, and other languages with hybrid type checking, typically enforce function types by dynamically generating function proxies. This approach can result in unbounded growth in the number of proxies, however, which drastically impacts space efficiency and destroys tail recursion.
We present a semantics for gradual typing that is based on coercions instead of function proxies, and which combines adjacent coercions at runtime to limit their space consumption. We prove bounds on the space consumed by coercions as well as soundness of the type system, demonstrating that programmers can safely mix typing disciplines without incurring unreasonable overheads. Our approach also detects certain errors earlier than prior work.
Similar content being viewed by others
References
Ahmed, A., Findler, R.B., Matthews, J., Wadler, P.: Blame for all. In: Workshop on Script to Program Evolution (2009)
Birtwhistle, G.M., et al.: Simula Begin. Chartwell-Bratt Ltd., Bromley (1979)
Blume, M., McAllester, D.: Sound and complete models of contracts. J. Funct. Program. 16(4–5), 375–414 (2006). ISSN 0956-7968. doi:10.1007/s10990-011-9066-z
Bracha, G.: Pluggable type systems. In: Workshop on Revival of Dynamic Languages, October 2004
Brus, T., van Eekelen, M., van Leer, M., Plasmeijer, M.: Clean nnn a language for functional graph rewriting. In: Kahn, G. (ed.) Functional Programming Languages and Computer Architecture. Lecture Notes in Computer Science, vol. 274, pp. 364–384. Springer, Berlin (1987)
Cardelli, L.: Amber. In: Spring School of the LITP on Combinators and Functional Programming Languages, pp. 21–47 (1986)
Cardelli, L., Donahue, J., Glassman, L., Jordan, M., Kalsow, B., Nelson, G.: Modula-3 report (revised). Technical Report 52, DEC SRC (1989)
Chambers, C.: The Cecil Language Specification and Rationale: Version 3.0. University of Washington (1998)
Clements, J.: Portable and high-level access to the stack with Continuation Marks. PhD thesis, Northeastern University (2005)
Clements, J., Felleisen, M.: A tail-recursive machine with stack inspection. ACM Trans. Program. Lang. Syst. 26(6), 1029–1052 (2004)
de Oliveira, R.B.: The Boo programming language (2005)
ECMAScript Edition 4 group wiki. Ecma International (2007)
ECMAScript Language Specification. Ecma International, 5th edn. (2009). URL http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf
Findler, R.B., Blume, M.: Contracts as pairs of projections. In: Proceedings of the International Symposium on Functional and Logic Programming (FLOPS), pp. 226–241 (2006)
Findler, R.B., Felleisen, M.: Contracts for higher-order functions. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP), pp. 48–59, October 2002
Flanagan, C.: Hybrid type checking. In: Proceedings of the ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pp. 245–256 (2006)
Flanagan, C., Freund, S.N., Tomb, A.: Hybrid types, invariants, and refinements for imperative objects. In: The International Workshop on Foundations and Developments of Object-Oriented Languages (FOOL/WOOD) (2006)
Ganz, S.E., Friedman, D.P., Wand, M.: Trampolined style. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP), pp. 18–27 (1999)
Greenberg, M., Pierce, B., Weirich, S.: Contracts made manifest. In: Proceedings of the ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL) (2010)
Gronski, J., Knowles, K., Tomb, A., Freund, S.N., Flanagan, C.: Sage: Hybrid checking for flexible specifications. In: Scheme and Functional Programming Workshop, September 2006
Guha, A., Matthews, J., Findler, R.B., Krishnamurthi, S.: Relationally-parametric polymorphic contracts. In: DLS, pp. 29–40 (2007)
Henglein, F.: Dynamic typing: Syntax and proof theory. Sci. Comput. Program. 22(3), 197–230 (1994)
Herman, D., Tomb, A., Flanagan, C.: Space-efficient gradual typing. In: Trends in Functional Programming (TFP) (2007)
Knowles, K.W., Flanagan, C.: Hybrid type checking. ACM Trans. Program. Lang. Syst. 32(2) (2010)
Matthews, J., Findler, R.B.: Operational semantics for multi-language programs. In: Proceedings of the ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL) (2007)
Meijer, E., Drayton, P.: Static typing where possible, dynamic typing when needed. In: Workshop on Revival of Dynamic Languages (2005)
Minamide, Y., Garrigue, J.: On the runtime complexity of type-directed unboxing. In: Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP), pp. 1–12 (1998)
Ou, X., Tan, G., Mandelbaum, Y., Walker, D.: Dynamic typing with dependent types. In: Proceedings of the IFIP International Conference on Theoretical Computer Science, pp. 437–450 (2004)
Pil, M.: First class file I/O. In: IFL ’96: Selected Papers from the 8th International Workshop on Implementation of Functional Languages, pp. 233–246, London, UK. Springer, Berlin (1997). ISBN 3-540-63237-9
Siek, J., Wadler, P.: Exploring the design space of higher-order casts. In: Proceedings of the ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL) (2010)
Siek, J., Garcia, R., Taha, W.: Exploring the design space of higher-order casts. In: Proceedings of the European Symposium on Programming Languages and Systems (ESOP), pp. 17–31. Springer, Berlin (2009)
Siek, J.G., Taha, W.: Gradual typing for functional languages. In: Scheme and Functional Programming Workshop, September 2006
Siek, J.G., Taha, W.: Gradual typing for objects. In: Proceedings of the European Conference on Object-Oriented Programming (ECOOP), Berlin, Germany, July 2007
Tobin-Hochstadt, S., Felleisen, M.: Interlanguage migration: From scripts to programs. In: Dynamic Languages Symposium, October 2006
Tobin-Hochstadt, S., Felleisen, M.: The design and implementation of typed scheme. In: Proceedings of the ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), pp. 395–406 (2008)
Wallach, D.S.: A New Approach to Mobile Code Security. PhD thesis, Princeton University, Department of Computer Science (1999)
Wright, A.K.: Practical Soft Typing. PhD thesis, Rice University (August 1998)
Xu, D.N., Peyton Jones, S.L., Claessen, K.: Static contract checking for Haskell. In: POPL, pp. 41–52 (2009)
Author information
Authors and Affiliations
Corresponding author
Additional information
David Herman was supported by a grant from the Mozilla Corporation. Cormac Flanagan was supported by a Sloan Fellowship and by NSF grant CCS-0341179. Aaron Tomb was also supported by NSF grant CCS-0341179. For Herman, most of this work was done at Northeastern University, Boston, MA.
Rights and permissions
About this article
Cite this article
Herman, D., Tomb, A. & Flanagan, C. Space-efficient gradual typing. Higher-Order Symb Comput 23, 167–189 (2010). https://doi.org/10.1007/s10990-011-9066-z
Published:
Issue Date:
DOI: https://doi.org/10.1007/s10990-011-9066-z