skip to main content
research-article

A formalization of typed lua

Published:21 October 2015Publication History
Skip Abstract Section

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.

References

  1. E. Allende, O. Calla´u, J. Fabry, É. Tanter, and M. Denker. Gradual typing for Smalltalk. Science of Computer Programming, Aug. 2013.Google ScholarGoogle Scholar
  2. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. A. Bonnaire-Sergeant, R. Davies, and S. Tobin-Hochstadt. Practical optional types for Clojure, 2015.Google ScholarGoogle Scholar
  5. G. Bracha. Pluggable type systems. In Proc. of the Workshop on Revival of Dyn. Lang., OOPSLA, October 2004.Google ScholarGoogle Scholar
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. K. Clancy. Lua Analyzer, 2014.Google ScholarGoogle Scholar
  8. E. Ernerfeldt. Sol, 2013.Google ScholarGoogle Scholar
  9. F. Fleutot. Tidal Lock: Gradual static typing for Lua, 2013.Google ScholarGoogle Scholar
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. J. Lehtosalo. mypy: Optional static typing for Python, 2014.Google ScholarGoogle Scholar
  12. A. M. Maidl. Typed Lua: An Optional Type System for Lua. PhD thesis, PUC-Rio, 2015.Google ScholarGoogle Scholar
  13. 1 Available at https://github.com/andremm/typedlua.Google ScholarGoogle Scholar
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle Scholar
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. B. C. Pierce. Types and Programming Languages. MIT Press, Cambridge, MA, USA, 2002. ISBN 0-262-16209-1. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. 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 ScholarGoogle Scholar
  19. J. G. Siek and W. Taha. Gradual typing for functional languages. In Scheme and Func. Prog. Workshop, pages 81–92, September 2006.Google ScholarGoogle Scholar
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. J. G. Siek, M. M. Vitousek, and S. Bharadwaj. Gradual typing for mutable objects. Technical report, University of Colorado, 2013. {to be published}.Google ScholarGoogle Scholar
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. A formalization of typed lua

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 51, Issue 2
        DLS '15
        Feburary 2016
        176 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2936313
        • Editor:
        • Andy Gill
        Issue’s Table of Contents
        • cover image ACM Conferences
          DLS 2015: Proceedings of the 11th Symposium on Dynamic Languages
          October 2015
          176 pages
          ISBN:9781450336901
          DOI:10.1145/2816707

        Copyright © 2015 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 21 October 2015

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!