Advertisement

Making type inference practical

  • Nicholas Oxhøj
  • Jens Palsberg
  • Michael I. Schwartzbach
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 615)

Abstract

We present the implementation of a type inference algorithm for untyped object-oriented programs with inheritance, assignments, and late binding. The algorithm significantly improves our previous one, presented at OOPSLA'91, since it can handle collection classes, such as List, in a useful way. Abo, the complexity has been dramatically improved, from exponential time to low polynomial time. The implementation uses the techniques of incremental graph construction and constraint template instantiation to avoid representing intermediate results, doing superfluous work, and recomputing type information. Experiments indicate that the implementation type checks as much as 100 lines pr. second. This results in a mature product, on which a number of tools can be based, for example a safety tool, an image compression tool, a code optimization tool, and an annotation tool. This may make type inference for object-oriented languages practical.

Keywords

Type Variable Minimal Solution Global Constraint Local Constraint Type Inference 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [1]
    Alan H. Borning and Daniel H. H. Ingalls. A type declaration and inference system for Smalltalk. In Ninth Symposium on Principles of Programming Languages, pages 133–141. ACM Press, January 1982.Google Scholar
  2. [2]
    Luca Cardelli. A semantics of multiple inheritance. In Gilles Kahn, David Mac-Queen, and Gordon Plotkin, editors, Semantics of Data Types, pages 51–68. Springer-Verlag (LNCS 173), 1984.Google Scholar
  3. [3]
    Luca Cardelli and Peter Wegner. On understanding types, data abstraction, and polymorphism. ACM Computing Surveys, 17(4):471–522, December 1985.CrossRefGoogle Scholar
  4. [4]
    William Cook and Jens Palsberg. A denotational semantics of inheritance and its correctness. In Proc. OOPSLA'89, ACM SIGPLAN Fourth Annual Conference on Object-Oriented Programming Systems, Languages and Applications, 1989. To appear in Information and Computation.Google Scholar
  5. [5]
    William R. Cook. A Denotational Semantics of Inheritance. PhD thesis, Brown University, 1989.Google Scholar
  6. [6]
    Ole-Johan Dahl, BjØrn Myhrhaug, and Kristen Nygaard. Simula 67 common base language. Technical report, Norwegian Computing Center, Oslo, Norway, 1968.Google Scholar
  7. [7]
    Scott Danforth and Chris Tomlinson. Type theories and object-oriented programming. ACM Computing Surveys, 20(1), March 1988.Google Scholar
  8. [8]
    Adele Goldberg and David Robson. Smalltalk-80—The Language and its Implementation. Addison-Wesley, 1983.Google Scholar
  9. [9]
    Justin O. Graver and Ralph E. Johnson. A type system for Smalltalk. In Seventeenth Symposium on Principles of Programming Languages, pages 136–150. ACM Press, January 1990.Google Scholar
  10. [10]
    Justin Owen Graver. Type-Checking and Type-Inference for Object-Oriented Programming Languages. PhD thesis, Department of Computer Science, University of Illinois at Urbana-Champaign, August 1989. UIUCD-R-89-1539.Google Scholar
  11. [11]
    Andreas V. Hense. Polymorphic type inference for a simple object oriented programming language with state. Technical Report No. A 20/90, Fachbericht 14, UniversitÄt des Saarlandes, December 1990.Google Scholar
  12. [12]
    Andreas V. Hense. Wrapper semantics of an object-oriented programming language with state. In T. Ito and A. R. Meyer, editors, Proc. Theoretical Aspects of Computer Software, pages 548–568. Springer-Verlag (LNCS 526), 1991.Google Scholar
  13. [13]
    Urs Hölzle, Craig Chambers, and David Ungar. Optimizing dynamically-typed object-oriented languages with polymorphic inline caches. In Proc. ECOOP'91, Fifth European Conference on Object-Oriented Programming, 1991.Google Scholar
  14. [14]
    Samuel Kamin. Inheritance in Smalltalk-80: A denotational definition. In Fifteenth Symposium on Principles of Programming Languages, pages 80–87. ACM Press, January 1988.Google Scholar
  15. [15]
    Bent B. Kristensen, Ole Lehrmann Madsen, Birger MØller-Pedersen, and Kristen Nygaard. The BETA programming language. In Bruce Shriver and Peter Wegner, editors, Research Directions in Object-Oriented Programming, pages 7–48. MIT Press, 1987.Google Scholar
  16. [16]
    Bertrand Meyer. Object-Oriented Software Construction. Prentice-Hall, Englewood Cliffs, NJ, 1988.Google Scholar
  17. [17]
    Nicholas OxhØj, Jens Palsberg, and Michael I. Schwartzbach. Making type inference practical. Technical Report DAIMI PB-385, Computer Science Department, Aarhus University, 1992.Google Scholar
  18. [18]
    Jens Palsberg and Michael I. Schwartzbach. Object-oriented type inference. In Proc. OOPSLA'91, ACM SIGPLAN Sixth Annual Conference on Object-Oriented Programming Systems, Languages and Applications, 1991.Google Scholar
  19. [19]
    Jens Palsberg and Michael I. Schwartzbach. Static typing for object-oriented programming. Computer Science Department, Aarhus University. PB-355. Submitted for publication, 1991.Google Scholar
  20. [20]
    Jens Palsberg and Michael I. Schwartzbach. What is type-safe code reuse? In Proc. ECOOP'91, Fifth European Conference on Object-Oriented Programming. Springer-Verlag (LNCS 512), 1991.Google Scholar
  21. [21]
    Uday S. Reddy. Objects as closures: Abstract semantics of object-oriented languages. In Proc. ACM Conference on Lisp and Functional Programming, pages 289–297. ACM, 1988.Google Scholar
  22. [22]
    Didier Rémy. Typechecking records and variants in a natural extension of ML. In Sixteenth Symposium on Principles of Programming Languages, pages 77–88. ACM Press, January 1989.Google Scholar
  23. [23]
    Michael I. Schwartzbach. Type inference with inequalities. In Proc. TAPSOFT'91. Springer-Verlag (LNCS 493), 1991.Google Scholar
  24. [24]
    Bjarne Stroustrup. The C++ Programming Language. Addison-Wesley, 1986.Google Scholar
  25. [25]
    Norihisa Suzuki. Inferring types in Smalltalk. In Eighth Symposium on Principles of Programming Languages, pages 187–199. ACM Press, January 1981.Google Scholar
  26. [26]
    Mitchell Wand. A simple algorithm and proof for type inference. Fundamentae Informaticae, X:115–122, 1987.MathSciNetGoogle Scholar
  27. [27]
    Mitchell Wand. Type inference for record concatenation and multiple inheritance. In LICS'89, Fourth Annual Symposium on Logic in Computer Science, pages 92–97, 1989.Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 1992

Authors and Affiliations

  • Nicholas Oxhøj
    • 1
  • Jens Palsberg
    • 1
  • Michael I. Schwartzbach
    • 1
  1. 1.Computer Science DepartmentAarhus Universityårhus CDenmark

Personalised recommendations