skip to main content
research-article

Polymorphic type inference for scripting languages with object extensions

Published:24 October 2011Publication History
Skip Abstract Section

Abstract

This paper presents a polymorphic type inference algorithm for a small subset of JavaScript. The goal is to prevent accessing undefined members of objects. We define a type system that allows explicit extension of objects through add operation and implicit extension through method calls. The type system also permits strong updates and unrestricted extensions to new objects. The type inference algorithm is modular so that each function definition is only analyzed once and larger programs can be checked incrementally.

References

  1. M. Abadi and L. Cardelli. A Theory of Objects. Springer-Verlag New York, Inc., Secaucus, NJ, USA, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. O. Agesen. The Cartesian Product Algorithm: Simple and Precise Type Inference Of Parametric Polymorphism. In Proceedings of the 9th European Conference on Object-Oriented Programming (ECOOP'95), pages 2--26, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. O. Agesen, J. Palsberg, and M. I. Schwartzbach. Type Inference of SELF. In Proceedings of the 7th European Conference on Object-Oriented Programming (ECOOP'93), pages 247--267, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. C. Anderson, S. Drossopoulou, and P. Giannini. Towards Type Inference for JavaScript. In 19th European Conference on Object-Oriented Programming (ECOOP'05), pages 428--452, July 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. V. Bono and K. Fisher. An Imperative, First-Order Calculus with Object Extension. In the 12th European Conference on Object-Oriented Programming (ECOOP'98), pages 462--497, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. D. Crockford. JavaScript: The Good Parts. O'Reilly Media, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. P. Di Gianantonio, F. Honsell, and L. Liquori. A Lambda Calculus of Objects With Self-Inflicted Extension. In Object-Oriented Programming Systems, Languages, and Applications (OOPSLA'98), pages 166--178, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. J. Eifrig, S. Smith, and V. Trifonov. Sound Polymorphic Type Inference for Objects. SIGPLAN Not., 30 (10): 169--184, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. M. Furr, J.-h. D. An, and J. S. Foster. Profile guided static typing for dynamic scripting languages. In Object-Oriented Programming Systems, Languages, and Applications (OOPSLA'09), 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. M. Furr, J.-h. D. An, J. S. Foster, and M. Hicks. Static type inference for Ruby. In Proceedings of the 2009 ACM symposium on Applied Computing (SAC'09), pages 1859--1866, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. A. Guha, C. Saftoiu, and S. Krishnamurthi. Typing local control and state using flow analysis. In Proceedings of the 20th European conference on Programming languages and systems, pages 256--275, 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. P. Heidegger and P. Thiemann. Recency Types for Analyzing Scripting Languages. In Proceedings of the 24th European Conference on Object-Oriented Programming (ECOOP'10), pages 200--224, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. S. H. Jensen, A. Møller, and P. Thiemann. Type Analysis for JavaScript. In 16th International Static Analysis Symposium (SAS'09), August 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. N. Oxhøj, J. Palsberg, and M. I. Schwartzbach. Making Type Inference Practical. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP'92), pages 329--349, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. Palsberg. Efficient Inference of Object Types. Inf. Comput., 123 (2): 198--209, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. Palsberg and T. Zhao. Type Inference for Record Concatenation and Subtyping. Inf. Comput., 189 (1): 54--86, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. J. Palsberg, T. Zhao, and T. Jim. Automatic discovery of covariant read-only fields. ACM Trans. Program. Lang. Syst., 27 (1): 126--162, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. J. Plevyak and A. A. Chien. Precise Concrete Type Inference for Object-Oriented Languages. In Proceedings of the 9th annual conference on Object-oriented programming systems, language, and applications (OOPSLA'94), pages 324--340, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. G. Richards, S. Lesbrene, B. Burg, and J. Vitek. An Analysis of the Dynamic Behavior of JavaScript Programs. In Proceedings of the ACM Programming Language Design and Implementation Conference (PLDI), June 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. M. Salib. Faster than C: Static Type Inference with Starkiller. In in PyCon Proceedings, Washington DC, pages 2--26, 2004.Google ScholarGoogle Scholar
  21. S. A. Spoon and O. Shivers. Demand-Driven Type Inference with Subgoal Pruning: Trading Precision for Scalability. In Proceedings of the 18th European Conference on Object-Oriented Programming, (ECOOP'04), pages 51--74, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  22. P. Thiemann. Towards a Type System for Analyzing JavaScript Programs. In 14th European Symposium on Programming (ESOP'05), pages 408--422, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. S. Tobin-Hochstadt and M. Felleisen. The design and implementation of typed scheme. In Proceedings of the 35th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages, POPL '08, pages 395--406, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. T. Wang and S. F. Smith. Precise Constraint-Based Type Inference for Java. In Proceedings of the 15th European Conference on Object-Oriented Programming (ECOOP'01), pages 99--117, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. T. Zhao. Type inference for scripting languages with implicit extension. In International Workshop on Foundations of Object-Oriented Languages, 2010.Google ScholarGoogle Scholar

Index Terms

  1. Polymorphic type inference for scripting languages with object extensions

        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 47, Issue 2
          DLS '11
          February 2012
          103 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2168696
          Issue’s Table of Contents
          • cover image ACM Conferences
            DLS '11: Proceedings of the 7th symposium on Dynamic languages
            October 2011
            114 pages
            ISBN:9781450309394
            DOI:10.1145/2047849
            • General Chair:
            • Theo D'Hondt

          Copyright © 2011 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 24 October 2011

          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!