Skip to main content

The Cartesian Product Algorithm

Simple and Precise Type Inference of Parametric Polymorphism

  • Conference paper
  • First Online:
ECOOP’95 — Object-Oriented Programming, 9th European Conference, Åarhus, Denmark, August 7–11, 1995 (ECOOP 1995)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 952))

Included in the following conference series:

Abstract

Concrete types and abstract types are different and serve different purposes. Concrete types, the focus of this paper, are essential to support compilation, application delivery, and debugging in object-oriented environments. Concrete types should not be obtained from explicit type declarations because their presence limits polymorphism unacceptably. This leaves us with type inference. Unfortunately, while polymorphism demands the use of type inference, it has also been the hardest challenge for type inference.

We review previous type inference algorithms that analyze code with parametric polymorphism and then present a new one: the cartesian product algorithm. It improves precision and efficiency over previous algorithms and deals directly with inheritance, rather than relying on a preprocessor to expand it away. Last, but not least, it is conceptually simple.

The cartesian product algorithm has been used in the Self system since late 1993. We present measurements to document its performance and compare it against several previous algorithms.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 74.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Agesen, O., Constraint-Based Type Inference and Parametric Polymorphism. In SAS’94, First International Static Analysis Symposium, p. 78–100, Namur, Belgium, Sept. 1994. Springer-Verlag, LNCS 864.

    Google Scholar 

  2. Agesen, O., L. Bak, C. Chambers, B.W. Chang, U. Hölzle, I. Maloney, R.B. Smith, D. Ungar, M. Wolczko. How to use Self 3.0 & The Self 3.0 Programmer’s Reference Manual. 1993. Sun Microsystems Laboratories, 2550 Garcia Avenue, Mountain View, CA 94043, USA. Available by anon. ftp from self.stanford.edu or www: http://self.stanford.edu/.

  3. Agesen, O., J. Palsberg, and M.I. Schwartzbach, Type Inference of Self: Analysis of Objects with Dynamic and Multiple Inheritance. In ECOOP’93, Seventh European Conference on Object-Oriented Programming, p. 247–267, Kaiserslautern, Germany, July 1993. Springer-Verlag, LNCS 707.

    Google Scholar 

  4. Agesen, O. and D. Ungar, Sifting Out the Gold: Delivering Compact Applications from an Exploratory Object-Oriented Programming Environment. In OOPSLA’ 94, Object-Oriented Programming Systems, Languages and Applications, p. 355–370, Portland, Oregon, Oct. 1994.

    Google Scholar 

  5. Bobrow, D.G., K. Kahn, G. Kiczales, L. Masinter, M. Stefik, and F. Zdybel, Common-Loops: Merging Lisp and Object-Oriented Programming. In OOPSLA’ 86 Object-Oriented Programming Systems, Languages and Applications, p. 17–29, Portland, Oregon, Sept. 1986.

    Google Scholar 

  6. Chambers, C., Object-Oriented Multi-Methods in Cecil. In ECOOP’92, Sixth European Conference on Object-Oriented Programming, p. 33–56, June 1992, Utrecht, The Netherlands. Springer-Verlag, LNCS 615.

    Chapter  Google Scholar 

  7. Chambers, C., D. Ungar, Making Pure Object-Oriented Languages Practical. In OOPSLA’ 91, Sixth Annual Conference on Object-Oriented Programming Systems, Languages and Applications, p. 1–15, Phoenix, Arizona, Oct. 1991.

    Google Scholar 

  8. Chambers, C., D. Ungar, and E. Lee, An Efficient Implementation of SELF, a Dynamically-Typed Object-Oriented Language Based on Prototypes. Lisp and Symbolic Computation 4(3), p. 243–281, Kluwer Academic Publishers, June 1991. (Originally published in Proc. OOPSLA’89).

    Article  Google Scholar 

  9. Cousot, P. and R. Cousot, Abstract Interpretation: A Unified Lattice Model for Static Analysis of Programs by Construction or Approximation of Fixpoints. In Conference Record of the Fourth ACM Symposium on Principles of Programming Languages, p. 238–252, Jan. 1977.

    Google Scholar 

  10. Graver, J.O., Type-Checking and Type-Inference for Object-Oriented Programming Languages, Ph.D. thesis, University of Illinois at Urbana-Champaign, 1989.

    Google Scholar 

  11. Graver, J.O. and R.E. Johnson, A Type System for Smalltalk. In Conference Record of the Seventeenth Annual ACM Symposium on Principles of Programming Languages, p. 136–150, San Francisco, California, Jan. 1990.

    Google Scholar 

  12. Hunt, J.W. and T.G. Szymanski, A Fast Algorithm for Computing Longest Common Subsequences, Communications of the ACM, 20(5), p. 350–353, May 1977.

    Article  MATH  MathSciNet  Google Scholar 

  13. Hölzle, U., Why Static Typing is not Important for Efficiency. In: J. Palsberg & M.I. Schwartzbach (eds.) Types, Inheritance, and Assignment, Technical Report, Daimi PB-357, Computer Science Department, Aarhus University, Denmark, June 1991.

    Google Scholar 

  14. Hölzle, U. and D. Ungar, Optimizing Dynamically-Dispatched Calls with Run-time Type Feedback. In PLDI’94, Conference on Programming Language Design and Implementation, p. 326–336, Orlando, Florida, June 1994.

    Google Scholar 

  15. Johnson, R.E., Type-Checking Smalltalk. In OOPSLA’86 Object-Oriented Programming Systems, Languages and Applications, p. 315–321, Portland, Oregon, Sept. 1986.

    Google Scholar 

  16. Milner, R., A Theory of Type Polymorphism in Programming. Journal of Computer and System Sciences, 17, p. 348–375, 1978.

    Article  MATH  MathSciNet  Google Scholar 

  17. Oxhøj, N., J. Palsberg, and M.I. Schwartzbach, Making Type Inference Practical. In ECOOP’92, Sixth European Conference on Object-Oriented Programming, p. 329–349, Utrecht, The Netherlands, June 1992, Springer-Verlag, LNCS 615.

    Chapter  Google Scholar 

  18. Palsberg, J. and M.I. Schwartzbach, Object-Oriented Type Inference. In OOPSLA’91 Object-Oriented Programming Systems, Languages and Applications, p. 146–161, Phoenix, Arizona, Oct. 1991.

    Google Scholar 

  19. Phillips, G. and T. Shepard, Static Typing Without Explicit Types. Technical Report, Dept. of Electrical and Computer Engineering, Royal Military College of Canada, Kingston, Ontario, Canada, 1994.

    Google Scholar 

  20. Plevyak, J. and A.A. Chien, Precise Concrete Type Inference for Object-Oriented Languages. In OOPSLA’ 94, Object-Oriented Programming Systems, Languages and Applications, p. 324–340, Portland, Oregon, Oct. 1994.

    Google Scholar 

  21. Plevyak, J., X. Zhang, and A.A. Chien, Obtaining Sequential Efficiency in Concurrent Object-Oriented Programs. In Conference Record of the 22nd Symposium on Principles of Programming Languages, p. 311–321, San Francisco, California, Jan. 1995

    Google Scholar 

  22. Sanella, M., J. Maloney, B. Freeman-Benson, A. Borning, Multi-way versus One-way Constraints in User Interfaces: Experience with the DeltaBlue Algorithm. Software — Practice and Experience, 23(5), p. 529–566, May 1993.

    Article  Google Scholar 

  23. Suzuki, N., Inferring Types in Smalltalk, In Conference Record of the Eighth Annual ACM Symposium on Principles of Programming Languages, p. 187–199, Williamsburg, Virginia, Jan. 1981.

    Google Scholar 

  24. Ungar, D. and R.B. Smith, SELF: The Power of Simplicity. Lisp and Symbolic Computing, 4(3), p. 187–205, Kluwer Academic Publishers, June 1991. (Originally published in Proc. OOPSLA’87).

    Article  Google Scholar 

  25. Vitek, J., N. Horspool, and J.S. Uhl, Compile-Time Analysis of Object-Oriented Programs. In Compiler Construction 4th International Conference, CC’92, p. 236–250, Paderborn, Germany, Oct. 1992, Springer-Verlag LNCS 641.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 1995 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Agesen, O. (1995). The Cartesian Product Algorithm. In: Tokoro, M., Pareschi, R. (eds) ECOOP’95 — Object-Oriented Programming, 9th European Conference, Åarhus, Denmark, August 7–11, 1995. ECOOP 1995. Lecture Notes in Computer Science, vol 952. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-49538-X_2

Download citation

  • DOI: https://doi.org/10.1007/3-540-49538-X_2

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-60160-9

  • Online ISBN: 978-3-540-49538-3

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics