skip to main content
10.1145/268946.268970acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
Article
Free Access

Dynamic typing as staged type inference

Published:21 January 1998Publication History

ABSTRACT

Dynamic typing extends statically typed languages with a universal datatype, simplifying programs which must manipulate other programs as data, such as distributed, persistent, interpretive and generic programs. Current approaches, however, limit the use of polymorphism in dynamic values, and can be syntactically awkward.We introduce a new approach to dynamic typing, based on staged computation, which allows a single type-reconstruction algorithm to execute partly at compile time and partly at run-time. This approach seamlessly extends a single type system to accommodate types that are only known at run-time, while still supporting both type inference and polymorphism. The system is significantly more expressive than other approaches. Furthermore it can be implemented efficiently; most of the type inference is done at compile-time, leaving only some residual unification for run-time.We demonstrate our approach by examples in a small polymorphic functional language, and present its type system, type reconstruction algorithm, and operational semantics. Our proposal could also be readily adapted to many other programming languages.

References

  1. 1.M. Abadi, L. Cardelli, B. Pierce, and G. Plotkin. Dynamic typing in a statically typed language. A CM Transactions on Programming Lan9uages and Systems, 13(2):237-268, Apr I99I. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. 2.M. Abadi, L. Cardelli, B. Pierce, and D. R&ny. Dynamic typing in polymorphic languages. Journal of Functional Programming, 5(1):111-130, Jan 1995.Google ScholarGoogle ScholarCross RefCross Ref
  3. 3.A. Aiken and E. L. Wimmers. Type inclusion constraints and type iafexence. In Proceedings of the A CM SIGPLAN Conference on Fundional Programming Languages and Computer Architecture, pages 31- 41, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. 4.A. Aiken, E. L. Wimmers, and T. K. Lakshman. Soft typing with conditional types. In Proceedings of the Twenty-First Annual A CM Symposium on Principles of Programming Languages, Portland, Oregon, pages 163- 173, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. 5.It. Barendregt. Introduction to generalized type systems. Journal of Functional Programming, 1(2):125- 154, 1991.Google ScholarGoogle ScholarCross RefCross Ref
  6. 6.H. P. Barendregt. Lambda calculi with types. In S. Abramsky, D. M. Gabbay, and T. S. tg. Maibaum, editors, Handbook of Logic in Computer Science, volume 2, chapter 2, pages 117-309. Oxford Science Publishers, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. 7.L. Cardelli, S. Martini, J. C. Mitchell, and A. Scedrov. An extension of system F with subtyping. Information and Computation, 109(1/2):4-56, 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 8.It. Cartwright and M. Fagan. Soft typing. In A CM SIGPLAN-91 Conference on Programmin9 Language Design and Implementation, Toronto, Ontario, pages 278-292. ACM Press, Jun 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. 9.R. Davies. A temporal logic approach to bindingtime analysis. In E. Clarke, editor, Proceedings of the Eleventh Annual IEEE Symposium on Logic in Computer Science, New Brunswick, New Jersey, pages 184- 195. IEEE Computer Society Press, 3ul 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. 10.tL Davies and F. Pfenning. A modal analysis of staged computation. In Proceedings of the 23rd Annual A CM SIQPLAN-SIGACT Symposium on Principles of Programming Languages, St. Petersburg Beach, Florida, pages 258-270. ACM Press, Jan 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. 11.C. Dubois, F. Rouaix, and P. Weis. Extensional polymorphism. In Proceedings of th~ ~nd Annual A CM SIGPLAN-SIGAGT Symposium on Principles of Programming Languages, San 1Wancisco, California, pages 118-129. ACM Press, Jan 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. 12.J.-Y. Girard. The system F of variable types, Fifteen years later. In G. Huet, editor, Logical Foundations of Functional Programming, The UT Year of Programruing Series, chapter 6. Addison-Wesley, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. 13.J. Hatcliff and O. Danvy. Thunks and the lambdacalculus. Journ'al of Functional Programming, 7(3):303- 319, May 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. 14.F. Henglein and J. Rehof. Safe polymorphic type inference for a dynamically '~yped language: Trauslating Scheme to ML. In Proceedings of the A CM SIGPLAN Conference on Runctional Programming Languages and Computer Arehitedure, pages 192-203. ACM Press, Jun 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 15.N. D. Jones, C. K. Gomard, and P. SestofL Partial E~aluation and Automatic Program Generation. Prentice Hall Iaxtexnational, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. 16.P. Lee and M. Leone. Optimizing ML with rua-time code generation. In A CM SIGPLAI~-#a Conference on Programming Language Design and Implementation, pages 137-148, Philadelphia, Penasylvaaia, May 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. 17.X. Leroy and M. Maamy. Dynamics in ML. Journal of .b'~netionaI Programming, 3(4):431-463, 1993.Google ScholarGoogle Scholar
  18. 18.Microsoft. The component object model specification. Technical report, Microsoft Corporation, 1995. oGoogle ScholarGoogle Scholar
  19. 19.R. Milner. A theory of type polymorphism in programming. Journal. of Computer and System Sciences, 17:348-375, 1978.Google ScholarGoogle ScholarCross RefCross Ref
  20. 20.E. Moggi. A categorical accoun~ of two-level languages. In Proceedings of the Thirteenfh Annual Conference on Mathematical Foundations of Programmiz9 Semantics, Electronic No~es in Theoretical Computer Science Volume 6. Blsevier Science Publishers, 1997.Google ScholarGoogle Scholar
  21. 21.A. Mycroft. Dyn.amic types in ML. (unpublished drafe article), 1983.Google ScholarGoogle Scholar
  22. 22.F. Nielson and H. tL Nielsom Tuw-levet Functional Languages. Cambridge University Press, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. 23.M. Odersky and K. L~iufer. Pu~t~g type annotations to work. In Proceedings of the 23rd Annual A GM SIGPLAN-SIGAGT Symposium on Principles of Programming Languages, St. Petersburg Beach, Flo~ida, pages 54-67. ACM Press, Jan 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. 24.J. Paterson and K. Hammond. Report or~ the Programming Language Haskell (Version 1.4), Apt 1997.Google ScholarGoogle Scholar
  25. 25.M. Shields, "i". Sheaxd, and S. Pey~on Jones. Dynamic typing as staged type inference. Technical Report TR.-I997-26, University of Glasgow, Depar~men~ of Computing Science, Aug 1997. Available from http: //~. des. gla. ac. uk/'rab s/pub / t r_97.26, ps, gz,Google ScholarGoogle Scholar
  26. 26.W. Taha and T. Shear& Mul~i-s~age programming with explicit annotations. In Partial Bvaluation and Se. mantles Based Program Analysis, pages 203-217, A0M Press, 1997'. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. 27.P. Wader and S. Blo~. How to make ad.hoc polymorphism less ad hoc. In Proceedings of the Six~eenD~ Annual A GM Symposium on Principles of Programming Languages, pages 60-76, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. 28.A. K. Wrigh~ and M. Felleisen. A syntactic approach to type soundness. Information and Computalion~ 115(1):38-94, Nov 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Dynamic typing as staged type inference

              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
              • Published in

                cover image ACM Conferences
                POPL '98: Proceedings of the 25th ACM SIGPLAN-SIGACT symposium on Principles of programming languages
                January 1998
                403 pages
                ISBN:0897919793
                DOI:10.1145/268946

                Copyright © 1998 ACM

                Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

                Publisher

                Association for Computing Machinery

                New York, NY, United States

                Publication History

                • Published: 21 January 1998

                Permissions

                Request permissions about this article.

                Request Permissions

                Check for updates

                Qualifiers

                • Article

                Acceptance Rates

                POPL '98 Paper Acceptance Rate32of175submissions,18%Overall Acceptance Rate824of4,130submissions,20%

                Upcoming Conference

                POPL '25

              PDF Format

              View or Download as a PDF file.

              PDF

              eReader

              View online with eReader.

              eReader