Abstract
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.
- E. Allende, O. Calla´u, J. Fabry, É. Tanter, and M. Denker. Gradual typing for Smalltalk. Science of Computer Programming, Aug. 2013.Google Scholar
- E. Allende, J. Fabry, and E. Tanter. Cast insertion strategies for gradually-typed objects. In Proc. of the 9th Symp. on Dyn. Lang., DLS ’13, pages 27–36, New York, NY, USA, 2013. ACM. Google Scholar
Digital Library
- A. P. Black, K. B. Bruce, M. Homer, J. Noble, A. Ruskin, and R. Yannow. Seeking Grace: A new object-oriented language for novices. In Proc. of the 44th ACM Tech. Symp. on Comp. Sci. Edu., SIGCSE ’13, pages 129–134, New York, NY, USA, 2013. ACM. Google Scholar
Digital Library
- A. Bonnaire-Sergeant, R. Davies, and S. Tobin-Hochstadt. Practical optional types for Clojure, 2015.Google Scholar
- G. Bracha. Pluggable type systems. In Proc. of the Workshop on Revival of Dyn. Lang., OOPSLA, October 2004.Google Scholar
- L. Cardelli. Amber. In Proc. of the 13th Spring School of the LITP, pages 21–47, London, UK, 1985. Springer-Verlag. ISBN 3-540-17184-3. Google Scholar
Digital Library
- K. Clancy. Lua Analyzer, 2014.Google Scholar
- E. Ernerfeldt. Sol, 2013.Google Scholar
- F. Fleutot. Tidal Lock: Gradual static typing for Lua, 2013.Google Scholar
- A. Guha, C. Saftoiu, and S. Krishnamurthi. Typing local control and state using flow analysis. In Proc. of the 20th European Conf. on Prog. Lang. and Systems, ESOP’11, pages 256–275, Berlin, Heidelberg, 2011. Springer-Verlag. Google Scholar
Digital Library
- J. Lehtosalo. mypy: Optional static typing for Python, 2014.Google Scholar
- A. M. Maidl. Typed Lua: An Optional Type System for Lua. PhD thesis, PUC-Rio, 2015.Google Scholar
- 1 Available at https://github.com/andremm/typedlua.Google Scholar
- A. M. Maidl, F. Mascarenhas, and R. Ierusalimschy. Typed Lua: An optional type system for Lua. In Proc. of the Workshop on Dyn. Lang. and App., Dyla’14, pages 3:1–3:10, New York, NY, USA, 2014. ACM. ISBN 978-1-4503-2916-3. Google Scholar
Digital Library
- H. Muhammad, F. Mascarenhas, and R. Ierusalimschy. LuaRocks: a declarative and extensible package management system for Lua. In Brazilian Symp. on Prog. Lang., pages 16–30. Springer, 2013.Google Scholar
- D. J. Pearce. A calculus for constraint-based flow typing. In Proc. of the 15th Workshop on Formal Tech. for Java-like Programs, FTfJP ’13, pages 7:1–7:7, New York, NY, USA, 2013. ACM. Google Scholar
Digital Library
- B. C. Pierce. Types and Programming Languages. MIT Press, Cambridge, MA, USA, 2002. ISBN 0-262-16209-1. Google Scholar
Digital Library
- G. Richards, F. Z. Nardelli, and J. Vitek. Concrete Types for TypeScript. In J. T. Boyland, editor, 29th European Conf. on Object-Oriented Prog. (ECOOP 2015), volume 37, pages 76– 100, Dagstuhl, Germany, 2015. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik. ISBN 978-3-939897-86-6..Google Scholar
- J. G. Siek and W. Taha. Gradual typing for functional languages. In Scheme and Func. Prog. Workshop, pages 81–92, September 2006.Google Scholar
- J. G. Siek and W. Taha. Gradual typing for objects. In Proc. of the 21st European Conf. on Object-Oriented Prog., ECOOP’07, pages 2–27, Berlin, Heidelberg, 2007. Springer-Verlag. Google Scholar
Digital Library
- J. G. Siek, M. M. Vitousek, and S. Bharadwaj. Gradual typing for mutable objects. Technical report, University of Colorado, 2013. {to be published}.Google Scholar
- S. Tobin-Hochstadt and M. Felleisen. Interlanguage migration: From scripts to programs. In Comp. to the 21st ACM SIGPLAN Symp. on Object-oriented Prog. Sys., Lang., and App., OOPSLA ’06, pages 964–974, New York, NY, USA, 2006. ACM. Google Scholar
Digital Library
- S. Tobin-Hochstadt and M. Felleisen. The design and implementation of Typed Scheme. In Proc. of the 35th Annual ACM SIGPLAN-SIGACT Symp. on Princ. of Prog. Lang., POPL ’08, pages 395–406, New York, NY, USA, 2008. ACM. Google Scholar
Digital Library
- S. Tobin-Hochstadt and M. Felleisen. Logical types for untyped languages. In Proc. of the 15th ACM SIGPLAN Intl. Conf. on Func. Prog., ICFP ’10, pages 117–128, New York, NY, USA, 2010. ACM. Google Scholar
Digital Library
- M. M. Vitousek, A. M. Kent, J. G. Siek, and J. Baker. Design and evaluation of gradual typing for Python. In Proc. of the 10th ACM Symp. on Dyn. Lang., DLS ’14, pages 45–56, New York, NY, USA, 2014. ACM. Google Scholar
Digital Library
- J. Winther. Guarded type promotion: Eliminating redundant casts in Java. In Proc. of the 13th Workshop on Formal Tech. for Java-Like Programs, FTfJP ’11, pages 6:1–6:8, New York, NY, USA, 2011. ACM. Google Scholar
Digital Library
- T. Wrigstad, F. Z. Nardelli, S. Lebresne, J. Östlund, and J. Vitek. Integrating typed and untyped code in a scripting language. In Proc. of the 37th Annual ACM SIGPLAN-SIGACT Symp. on Princ. of Prog. Lang., POPL ’10, pages 377–388, New York, NY, USA, 2010. ACM. Google Scholar
Digital Library
Index Terms
A formalization of typed lua
Recommendations
A formalization of typed lua
DLS 2015: Proceedings of the 11th Symposium on Dynamic LanguagesProgrammers 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 ...
Typed Lua: An Optional Type System for Lua
Dyla'14: Proceedings of the Workshop on Dynamic Languages and ApplicationsDynamically typed languages trade flexibility and ease of use for safety, while statically typed languages prioritize the early detection of bugs, and provide a better framework for structure large programs. The idea of optional typing is to combine the ...
Interpretations of the gradually-typed lambda calculus
Scheme '12: Proceedings of the 2012 Annual Workshop on Scheme and Functional ProgrammingGradual typing is an approach to integrating static and dynamic type checking within the same language [Siek and Taha 2006]. Given the name "gradual typing", one might think that the most interesting aspect is the type system. It turns out that the ...






Comments