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 Scholar
Digital 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 Scholar
Digital 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 Scholar
Digital Library
- CARDELLI, L., AND MITCHELL , J. C. Operations on records. Mathematical Structures in Computer Science 1 (1991), 3--48.Google Scholar
Cross 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 Scholar
Digital 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 Scholar
Digital Library
- FELLEISEN, M., F INDLER , R. B., AND FLATT, M. Semantics Engineering with PLT Redex. MIT Press, 2009. Google Scholar
Digital 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 Scholar
Digital Library
- FINDLER , R. B., AND FELLEISEN, M. Contracts for higher-order functions. In International Conference on Functional Programming (2002), pp. 48--59. Google Scholar
Digital Library
- FISHER , K. S. Type Systems for Object-Oriented Programming Languages. PhD thesis, Stanford University, 1996. Google Scholar
Digital 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 Scholar
Digital 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 Scholar
Digital 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 Scholar
Digital 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 Scholar
Digital 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 Scholar
Digital 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 Scholar
Digital Library
- HERMAN, D., AND FLANAGAN, C. Status report: Specifying JavaScript with ML. In ML Workshop (2007). Google Scholar
Digital Library
- LAMPING, J. Typing the specialization interface. In Object-Oriented Programming, Systems, Languages, and Applications (1993), pp. 201--214. Google Scholar
Digital 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 Scholar
Digital 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 Scholar
Digital Library
- PIERCE , B., AND SUMII, E. A bisimulation for dynamic sealing. In Symposium on Principles of Programming Languages (2004), pp. 161--172. Google Scholar
Digital 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 Scholar
Digital 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 Scholar
Digital Library
- STRICKLAND, T. S., AND FELLEISEN, M. Contracts for first-class classes. In Dynamic Languages Symposium (2010), pp. 97--111. Google Scholar
Digital 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 Scholar
Digital Library
- TOBIN-HOCHSTADT, S., AND FELLEISEN, M. Interlanguage migration: from scripts to programs. In Dynamic Languages Symposium (2006), pp. 964-974. Google Scholar
Digital 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 Scholar
Digital Library
- TOBIN-HOCHSTADT, S., AND FELLEISEN, M. Logical types for untyped languages. In International Conference on Functional Programming (2010), pp. 117--128. Google Scholar
Digital 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 Scholar
Digital Library
- WRIGHT, A. K., AND FELLEISEN, M. A syntactic approach to type soundness. Information and Control (1994), 38--94. Google Scholar
Digital 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 Scholar
Digital 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 with union and intersection types
We propose a type system for functional languages with gradual types and set-theoretic type connectives and prove its soundness. In particular, we show how to lift the definition of the domain and result type of an application from non-gradual types to ...
Gradual typing for first-class classes
OOPSLA '12: Proceedings of the ACM international conference on Object oriented programming systems languages and applicationsDynamic 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 ...







Comments