A formalization of typed lua

Programmers often migrate from a dynamically typed to a statically typed language when their simple scripts evolve into complex programs. Optional type systems are one way of having both static and dynamic typing in the same language, while keeping its dynamically typed semantics. This makes evolving a program from dynamic to static typing a matter of describing the implied types that it is using and adding annotations to make those types explicit. Designing an optional type system for an existing dynamically typed language is challenging, as its types should feel natural to programmers that are already familiar with this language. In this work, we give a formal description of Typed Lua, an optional type system for Lua, with a focus on two of its novel type system features: incremental evolution of imperative record and object types that is both lightweight and type-safe, and projection types, a combination of flow typing, functions that return multiple values, and multiple assignment. While our type system is tailored to the features and idioms of Lua, its features can be adapted to other imperative scripting languages.

[1]  Jeremy G. Siek Gradual Typing for Functional Languages , 2006 .

[2]  Walid Taha,et al.  Gradual Typing for Objects , 2007, ECOOP.

[3]  Johnni Winther Guarded type promotion: eliminating redundant casts in Java , 2011, FTfJP@ECOOP.

[4]  Andrew P. Black,et al.  Seeking grace: a new object-oriented language for novices , 2013, SIGCSE '13.

[5]  Sam Tobin-Hochstadt,et al.  Practical Optional Types for Clojure , 2016, ESOP.

[6]  Sam Tobin-Hochstadt,et al.  The design and implementation of typed scheme , 2008, POPL '08.

[7]  David J. Pearce A calculus for constraint-based flow typing , 2013, FTfJP@ECOOP.

[8]  Benjamin C. Pierce,et al.  Types and programming languages: the next generation , 2003, 18th Annual IEEE Symposium of Logic in Computer Science, 2003. Proceedings..

[9]  Jan Vitek,et al.  Concrete Types for TypeScript , 2015, ECOOP.

[10]  Gilad Bracha Pluggable Type Systems , 2004 .

[11]  Marcus Denker,et al.  Gradual typing for Smalltalk , 2014, Sci. Comput. Program..

[12]  Jim Baker,et al.  Design and evaluation of gradual typing for python , 2014, DLS.

[13]  Shriram Krishnamurthi,et al.  Typing Local Control and State Using Flow Analysis , 2011, ESOP.

[14]  Éric Tanter,et al.  Cast insertion strategies for gradually-typed objects , 2013, DLS '13.

[15]  André Murbach Maidl,et al.  Typed Lua: An Optional Type System for Lua , 2014, Dyla'14.

[16]  Jan Vitek,et al.  Integrating typed and untyped code in a scripting language , 2010, POPL '10.

[17]  Sam Tobin-Hochstadt,et al.  Interlanguage migration: from scripts to programs , 2006, OOPSLA '06.

[18]  Sam Tobin-Hochstadt,et al.  Logical types for untyped languages , 2010, ICFP '10.

[19]  Fabio Mascarenhas,et al.  LuaRocks - A Declarative and Extensible Package Management System for Lua , 2013, SBLP.