Abstract
Developers using statically typed languages such as C\(^\sharp\) and Java are increasingly having to interoperate with APIs and object models defined in dynamic languages. This impedance mismatch results in code that is difficult to understand, awkward to analyze, and expensive to maintain. In this paper we describe new features in C\(^\sharp\) 4.0 that support the safe combination of dynamically and statically typed code by deferring type checking of program fragments with static type dynamic until runtime. When executed, these dynamic code fragments are type-checked and resolved using the same rules as statically typed code. We formalize these features in a core fragment of C\(^\sharp\) and prove important safety properties. In particular, we show that subtyping remains transitive.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
Abadi, M., Cardelli, L., Pierce, B.C., Plotkin, G.D.: Dynamic typing in a statically-typed language. In: Proceedings of POPL (1989)
Aiken, A., Wimmers, E.L., Lakshman, T.K.: Soft typing with conditional types. In: Proceedings of POPL (1994)
Anderson, C., Drossopoulou, S.: BabyJ: From object based to class based programming via types. In: Proceedings of WOOD (2003)
Bierman, G.M.: Formalizing and extending C\(^{\sharp}\) type inference. In: Proceedings of FOOL (2007)
Bierman, G.M., Meijer, E., Torgersen, M.: Lost in translation: Formalizing proposed extensions to C\(^{\sharp}\). In: Proceedings of OOPSLA (2007)
Bierman, G.M., Parkinson, M.J.: Effects and effect inference for a core Java calculus. In: Proceedings of WOOD (2003)
Bierman, G.M., Parkinson, M.J., Pitts, A.M.: MJ: An imperative core calculus for Java and Java with effects. Technical Report 563, University of Cambridge (2003)
Breazu-Tannen, V., Coquand, T., Gunter, C.A., Scedrov, A.: Inheritance as implicit coercion. Information and computation 93(1), 172–221 (1991)
Cartwright, R., Fagan, M.: Soft typing. In: Proceedings of PLDI (1991)
Findler, R., Wadler, P.: Well-typed programs can’t be blamed. In: Proceedings of ESOP (2009)
Flatt, M., Krishnamurthi, S., Felleisen, M.: Classes and mixins. In: Proceedings of POPL (1998)
Hejlsberg, A., Torgersen, M., Wiltamuth, S., Golde, P.: The C\(^\sharp\) Programming Language, 3rd edn. Addison-Wesley, Reading (2009)
Henglein, F.: Dynamic typing: syntax and proof theory. Science of Computer Programming 22(3), 197–230 (1994)
Igarashi, A., Pierce, B.C., Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. ACM TOPLAS 23(3), 396–450 (2001)
Kennedy, A., Syme, D.: Transposing F to C\(^\sharp\). Concurrency and Computation 16(7) (2004)
Knowles, K., Tomb, A., Gronski, J., Freund, S.N., Flanagan, C.: Sage: Unified hybrid checking for first-class types, general refinement types and Dynamic. Technical report, UCSC (2007)
Meijer, E., Drayton, P.: Static typing where possible, dynamic typing when needed: The end of the cold war between programming languages. In: OOPSLA Workshop on Revival of Dynamic Languages (2004)
Pierce, B.C.: Types and programming languages. MIT Press, Cambridge (2002)
Pierce, B.C., Turner, D.N.: Local type inference. In: Proceedings of POPL (1998)
Siek, J., Taha, W.: Gradual typing for functional languages. In: Proceedings of Scheme and Functional Programming Workshop (2006)
Siek, J., Taha, W.: Gradual typing for objects. In: Proceedings of ECOOP (2007)
Thatte, S.: Quasi-static typing. In: Proceedings of POPL (1990)
Tobin-Hochstadt, S., Felleisen, M.: Interlanguage migration: From scripts to programs. In: Proceedings of DSL (2006)
Tobin-Hochstadt, S., Felleisen, M.: The design and implementation of Typed Scheme. In: Proceedings of POPL (2007)
Wrigstad, T., Zappa Nardelli, F., Lebresne, S., Östlund, J., Vitek, J.: Integrating typed and untyped code in a scripting language. In: Proceedings of POPL (2010)
Yu, D., Kennedy, A., Syme, D.: Formalization of generics for the .NET common language runtime. In: Proceedings of POPL (2004)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2010 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Bierman, G., Meijer, E., Torgersen, M. (2010). Adding Dynamic Types to C\(^\sharp\) . In: D’Hondt, T. (eds) ECOOP 2010 – Object-Oriented Programming. ECOOP 2010. Lecture Notes in Computer Science, vol 6183. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-14107-2_5
Download citation
DOI: https://doi.org/10.1007/978-3-642-14107-2_5
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-642-14106-5
Online ISBN: 978-3-642-14107-2
eBook Packages: Computer ScienceComputer Science (R0)