ABSTRACT
Dynamic type-checking and object-oriented programming often go hand-in-hand; scripting languages such as Python, Ruby, and JavaScript all embrace object-oriented (OO) programming. When scripts written in such languages grow and evolve into large programs, the lack of a static type discipline reduces maintainability. A programmer may thus wish to migrate parts of such scripts to a sister language with a static type system. Unfortunately, existing type systems neither support the flexible OO composition mechanisms found in scripting languages nor accommodate sound interoperation with untyped code. In this paper, we present the design of a gradual typing system that supports sound interaction between statically- and dynamically-typed units of class-based code. The type system uses row polymorphism for classes and thus supports mixin-based OO composition. To protect migration of mixins from typed to untyped components, the system employs a novel form of contracts that partially seal classes. The design comes with a theorem that guarantees the soundness of the type system even in the presence of untyped components.
- AHMED, A., FINDLER , R. B., SIEK , J. G., AND WADLER, P. Blame for all. In Symposium on Principles of Programming Languages (2011), pp. 201--214. Google ScholarDigital Library
- BIERMAN, G., MEIJER, E., AND TORGERSEN, M. Adding dynamic types to C#. In European Conference on Object-Oriented Programming (2010), pp. 76--100. Google ScholarDigital Library
- BONO, V., PATEL, A., AND SCHMATIKOV, V. A core calculus of classes and mixins. In European Conference on Object-Oriented Programming (1999), pp. 43--66. Google ScholarDigital Library
- CARDELLI, L., AND MITCHELL , J. C. Operations on records. Mathematical Structures in Computer Science 1 (1991), 3--48.Google ScholarCross Ref
- DIMOULAS , C., F INDLER , R. B., F LANAGAN, C., AND FELLEISEN, M. Correct blame for contracts: No more scape-goating. In Symposium on Principles of Programming Languages (2011), pp. 215 -- 226. Google ScholarDigital Library
- DIMOULAS , C., T OBIN-H OCHSTADT, S., AND FELLEISEN, M. Complete monitoring for behavioral contracts. In Euro-pean Symposium on Programming (2012), pp. 211--230. Google ScholarDigital Library
- FELLEISEN, M., F INDLER , R. B., AND FLATT, M. Semantics Engineering with PLT Redex. MIT Press, 2009. Google ScholarDigital Library
- FINDLER , R. B., C LEMENTS, J., F LANAGAN, C., F LATT, M., KRISHNAMURTHI, S., S TECKLER, P., AND FELLEISEN, M. DrScheme: A programming environment for Scheme. Journal of Functional Programming 12, 2 (2002), 159--182. Google ScholarDigital Library
- FINDLER , R. B., AND FELLEISEN, M. Contracts for higher-order functions. In International Conference on Functional Programming (2002), pp. 48--59. Google ScholarDigital Library
- FISHER , K. S. Type Systems for Object-Oriented Programming Languages. PhD thesis, Stanford University, 1996. Google ScholarDigital Library
- FLATT, M., F INDLER , R. B., AND FELLEISEN, M. Scheme with classes, mixins, and traits. In Asian Symposium on Programming Languages and Systems (2006), pp. 270--289. Google ScholarDigital Library
- FURR, M., A N, J.- H. D., F OSTER, J. S., AND HICKS , M. Static type inference for Ruby. In Symposium on Applied Computing (2009), pp. 1859--1866. Google ScholarDigital Library
- GASTER, B. R., AND J ONES, M. P. A polymorphic type system for extensible records and variants. Technical Report NOTTCS-TR-96-3, University of Nottingham, 1996.Google Scholar
- GRAY, K. E. Safe cross-language inheritance. In European Conference on Object-Oriented Programming (2008), pp. 52--75. Google ScholarDigital Library
- GRAY, K. E. Interoperability in a scripted world: Putting inheritance & prototypes together. In Foundations of Object-Oriented Languages (2011).Google Scholar
- GRAY, K. E., FINDLER , R. B., AND FLATT, M. Fine-grained interoperability through contracts and mirrors. In Object-Oriented Programming, Systems, Languages, and Applications (2005), pp. 231-245. Google ScholarDigital Library
- GUHA, A., MATTHEWS, J., F INDLER , R. B., AND KRISH-NAMURTHI, S. Relationally-parametric polymorphic con-tracts. In Dynamic Languages Symposium (2007), pp. 29--40. Google ScholarDigital Library
- HARPER, R., AND PIERCE , B. A records calculus based on symmetric concatenation. In Symposium on Principles of Programming Languages (1991), pp. 131--142. Google ScholarDigital Library
- HERMAN, D., AND FLANAGAN, C. Status report: Specifying JavaScript with ML. In ML Workshop (2007). Google ScholarDigital Library
- LAMPING, J. Typing the specialization interface. In Object-Oriented Programming, Systems, Languages, and Applications (1993), pp. 201--214. Google ScholarDigital Library
- MATTHEWS, J., AND AHMED, A. Parametric polymorphism through run-time sealing, or, theorems for low, low prices! In European Symposium on Programming (2008), pp. 16--31. Google ScholarDigital Library
- MATTHEWS, J., AND FINDLER , R. B. The meaning of multi-language programs. In Symposium on Principles of Programming Languages (2007), pp. 3--10.Google Scholar
- MEJER, E., AND 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).Google Scholar
- MORRIS, J R., J. H. Types are not sets. In Symposium on Principles of Programming Languages (1973), pp. 120--124. Google ScholarDigital Library
- PIERCE , B., AND SUMII, E. A bisimulation for dynamic sealing. In Symposium on Principles of Programming Languages (2004), pp. 161--172. Google ScholarDigital Library
- REMY, D. Programming objects with ML-ART an extension to ML with abstract and record types. In Theoretical Aspects of Computer Software (1994), pp. 321--346. Google ScholarDigital Library
- SIEK , J., AND TAHA, W. Gradual typing for functional languages. In Workshop on Scheme and Functional Programming (2006), pp. 81--92.Google Scholar
- SIEK , J., AND TAHA, W. Gradual typing for objects. In European Conference on Object-Oriented Programming (2007), pp. 2--27. Google ScholarDigital Library
- STRICKLAND, T. S., AND FELLEISEN, M. Contracts for first-class classes. In Dynamic Languages Symposium (2010), pp. 97--111. Google ScholarDigital Library
- TAKIKAWA, A., S TRICKLAND, T. S., D IMOULAS , C., TOBIN-H OCHSTADT, S., AND FELLEISEN, M. Gradual typ-ing for first-class classes. Technical Report NU-CCIS-12-02, Northeastern University, College of Computer and Information Science, 2012.Google Scholar
- TANG, A. Perl 6: reconciling the irreconcilable. Symposium on Principles of Programming Languages, 2007. Google ScholarDigital Library
- TOBIN-HOCHSTADT, S., AND FELLEISEN, M. Interlanguage migration: from scripts to programs. In Dynamic Languages Symposium (2006), pp. 964-974. Google ScholarDigital Library
- TOBIN-HOCHSTADT, S., AND FELLEISEN, M. The design and implementation of Typed Scheme. In Symposium on Principles of Programming Languages (2008), pp. 395--406. Google ScholarDigital Library
- TOBIN-HOCHSTADT, S., AND FELLEISEN, M. Logical types for untyped languages. In International Conference on Functional Programming (2010), pp. 117--128. Google ScholarDigital Library
- WAND, M. Complete type inference for simple objects. In Symposium on Logic in Computer Science (1987).Google Scholar
- WAND, M. Type inference for objects with instance variables and inheritance. In Theoretical Aspects of Object-Oriented Programming (1994), pp. 97--120. Google ScholarDigital Library
- WRIGHT, A. K., AND FELLEISEN, M. A syntactic approach to type soundness. Information and Control (1994), 38--94. Google ScholarDigital Library
- WRIGSTAD, T., NARDELLI, F. Z., L EBRESNE, S., OSTLUND, J., AND VITEK , J. Integrating typed and untyped code in a scripting language. In Symposium on Principles of Programming Languages (2010), pp. 377--388. Google ScholarDigital Library
Index Terms
- Gradual typing for first-class classes
Recommendations
Gradual typing: a new perspective
We define a new, more semantic interpretation of gradual types and use it to ``gradualize'' two forms of polymorphism: subtyping polymorphism and implicit parametric polymorphism. In particular, we use the new interpretation to define three gradual type ...
Gradual typing for first-class classes
OOPSLA '12Dynamic type-checking and object-oriented programming often go hand-in-hand; scripting languages such as Python, Ruby, and JavaScript all embrace object-oriented (OO) programming. When scripts written in such languages grow and evolve into large ...
On polymorphic gradual typing
We study an extension of gradual typing—a method to integrate dynamic typing and static typing smoothly in a single language—to parametric polymorphism and its theoretical properties, including conservativity of typing and semantics over both statically ...
Comments