ABSTRACT
How to integrate static and dynamic types? Recent work focuses on casts to mediate between the two. However, adding casts may degrade tail calls into a non-tail calls, increasing space consumption from constant to linear in the depth of calls.
We present a new solution to this old problem, based on the notion of a threesome. A cast is specified by a source and a target type--a twosome. Any twosome factors into a downcast from the source to an intermediate type, followed by an upcast from the intermediate to the target---a threesome. Any chain of threesomes collapses to a single threesome, calculated by taking the greatest lower bound of the intermediate types. We augment this solution with blame labels to map any failure of a threesome back to the offending twosome in the source program.
Herman, Tomb, and Flanagan (2007) solve the space problem by representing casts with the coercion calculus of Henglein (1994). While they provide a theoretical limit on the space overhead, there remains the practical question of how best to implement coercion reduction. The threesomes presented in this paper provide a streamlined data structure and algorithm for representing and normalizing coercions. Furthermore, threesomes provide a typed-based explanation of coercion reduction.
References
- M. Abadi, L. Cardelli, B. Pierce, and G. Plotkin. Dynamic typing in a statically-typed language. In POPL '89: Proceedings of the 16th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 213--227, New York, NY, USA, 1989. ACM. Google Scholar
Digital Library
- Martin Abadi, Luca Cardelli, Benjamin Pierce, and Gordon Plotkin. Dynamic typing in a statically typed language. ACM Transactions on Programming Languages and Systems, 13(2):237--268, April 1991. Google Scholar
Digital Library
- V. Breazu--Tannen, T. Coquand, C. Gunter, and A. Scedrov. Inheritance and explicit coercion. In Proceedings of the Fourth Annual Symposium on Logic in computer science, pages 112--129, Piscataway, NJ, USA, 1989. IEEE Press. Google Scholar
Digital Library
- L. Cardelli, J. Donahue, M. Jordan, B. Kalsow, and G. Nelson. The modula-3 type system. In POPL '89: Proceedings of the 16th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 202--212, New York, NY, USA, 1989. ACM. Google Scholar
Digital Library
- Luca Cardelli. Amber. In Combinators and Functional Programming Languages, volume 242, pages 21--70, 1986. Google Scholar
Digital Library
- R.B. Findler and M. Felleisen. Contracts for higher-order functions. In ACM International Conference on Functional Programming, October 2002. Google Scholar
Digital Library
- Cormac Flanagan. Hybrid type checking. In POPL 2006: The 33rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 245--256, Charleston, South Carolina, January 2006. Google Scholar
Digital Library
- Cormac Flanagan, Stephen N. Freund, and Aaron Tomb. Hybrid types, invariants, and refnements for imperative objects. In FOOL/WOOD '06: International Workshop on Foundations and Developments of Object-Oriented Languages, 2006.Google Scholar
- Kathryn E. Gray, Robert Bruce Findler, and Matthew Flatt. Fine-interoperability through mirrors and contracts. In OOPSLA '05: Proceedings of the 20th annual ACM SIGPLAN conference on Object oriented programming systems languages and applications, pages 231--245, New York, NY, USA, 2005. ACM Press. Google Scholar
Digital Library
- Jessica Gronski and Cormac Flanagan. Unifying hybrid types and contracts. In Trends in Functional Prog. (TFP), 2007.Google Scholar
- Jessica Gronski, Kenneth Knowles, Aaron Tomb, Stephen N. Freund, and Cormac Flanagan. Sage: Hybrid checking for flexible specifcations. In Scheme and Functional Programming Workshop, pages 93--104, 2006.Google Scholar
- Lars T. Hansen. Evolutionary programming and gradual typing in ECMAScript 4 (tutorial). Technical report, ECMA TG1 working group, November 2007.Google Scholar
- Anders Hejlsberg. The future of C#. http://channel9.msdn.com/pdc2008/TL16/, October 2008.Google Scholar
- Fritz Henglein. Dynamic typing. In ESOP '92: Proceedings of the 4th European Symposium on Programming, pages 233--253, London, UK, 1992. Springer-Verlag. Google Scholar
Digital Library
- Fritz Henglein. Dynamic typing: syntax and proof theory. Science of Computer Programming, 22(3):197--230, June 1994. Google Scholar
Digital Library
- David Herman, Aaron Tomb, and Cormac Flanagan. Space-effcient gradual typing. In Trends in Functional Prog. (TFP), page XXVIII, April 2007.Google Scholar
- Butler W. Lampson. A description of the Cedar language. Technical report, Xerox PARC, 1983.Google Scholar
- Barbara Liskov, Russ Atkinson, Toby Bloom, Eliot Moss, Craig Schaffert, Bob Scheifler, and Alan Snyder. CLU reference manual. Technical Report LCS-TR-225, MIT, October 1979. Google Scholar
Digital Library
- John C. Mitchell. Coercion and type inference. In POPL '84: Proceedings of the 11th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, pages 175--185, New York, NY, USA, 1984. ACM Press. Google Scholar
Digital Library
- P. Rovner. Extending Modula-2 to build large, integrated systems. IEEE Software, 3(6):46--57, 1986. ISSN 0740-7459. doi: http://doi.ieeecomputersociety.org/10.1109/MS.1986.229476. Google Scholar
Digital Library
- Dana Scott. Data types as lattices. SIAM Journal on Computing, 5(3): 522--587, 1976.Google Scholar
Digital Library
- Jeremy G. Siek and Walid Taha. Gradual typing for functional languages. In Scheme and Functional Programming Workshop, pages 81--92, September 2006.Google Scholar
- Jeremy G. Siek and Walid Taha. Gradual typing for objects. In ECOOP 2007, volume 4609 of LCNS, pages 2--27. Springer Verlag, August 2007. Google Scholar
Digital Library
- Jeremy G. Siek, Ronald Garcia, and Walid Taha. Exploring the design space of higher-order casts. In European Symposium on Programming, March 2009. Google Scholar
Digital Library
- Satish Thatte. Quasi-static typing. In POPL 1990, pages 367--381, New York, NY, USA, 1990. ACM Press. Google Scholar
Digital Library
- Sam Tobin-Hochstadt and Matthias Felleisen. Interlanguage migration: From scripts to programs. In OOPSLA'06 Companion, pages 964--974, NY, 2006. ACM. Google Scholar
Digital Library
- Sam Tobin-Hochstadt and Matthias Felleisen. The design and implementation of Typed Scheme. In POPL 2008: The 35th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, January 2008. Google Scholar
Digital Library
- Philip Wadler and Robert Bruce Findler. Well-typed programs can't be blamed. In Workshop on Scheme and Functional Programming, pages 15--26, 2007.Google Scholar
- Philip Wadler and Robert Bruce Findler. Well-typed programs can't be blamed. In European Symposium on Programming, 2009. Google Scholar
Digital Library
- Larry Wall. Synopsis 2: Bits and pieces. Technical report, June 2009.Google Scholar
- Tobias Wrigstad, Patrick Eugster, John Field, Nate Nystrom, and Jan Vitek. Software hardening: A research agenda. In International Workshop on Script to Program Evolution, July 2009. Google Scholar
Digital Library
Index Terms
Threesomes, with and without blame






Comments