skip to main content
10.1145/1028976.1029006acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
Article

Practical predicate dispatch

Published:01 October 2004Publication History

ABSTRACT

<i>Predicate dispatch</i> is an object-oriented (OO) language mechanism for determining the method implementation to be invoked upon a message send. With predicate dispatch, each method implementation includes a predicate guard specifying the conditions under which the method should be invoked, and logical implication of predicates determines the method overriding relation. Predicate dispatch naturally unifies and generalizes several common forms of dynamic dispatch, including traditional OO dispatch, multimethod dispatch, and functional-style pattern matching. Unfortunately, prior languages supporting predicate dispatch have had several deficiencies that limit its utility in practice.

We introduce JPred, a backward-compatible extension to Java supporting predicate dispatch. While prior languages with predicate dispatch have been extensions to toy or non-mainstream languages, we show how predicate dispatch can be naturally added to a traditional OO language. While prior languages with predicate dispatch have required the whole program to be available for type-checking and compilation, JPred retains Java's modular typechecking and compilation strategies. While prior languages with predicate dispatch have included special-purpose algorithms for reasoning about predicates, JPred employs general-purpose, off-the-shelf decision procedures. As a result, JPred's type system is more flexible, allowing several useful programming idioms that are spuriously rejected by those other languages. After describing the JPred language and type system, we present a case study illustrating the utility of JPred in a real-world application, including its use in the detection of several errors.

References

  1. H. Abelson, R. K. Dybvig, C. T. Haynes, G. J. Rozas, N. I. A. IV, D. P. Friedman, E. Kohlbecker, G. L. Steele Jr., D. H. Bartley, R. Halstead, D. Oxley, G. J. Sussman, G. Brooks, C. Hanson, K. M. Pitman, and M. Wand. Revised 5 report on the algorithmic language Scheme. Higher-Order and Symbolic Computation, 11(1):7--105, Aug. 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. D. Ancona, G. Lagorio, and E. Zucca. A formal framework for Java separate compilation. In Proceedings of the 2002 European Conference on Object-Oriented Programming, LNCS 2374, Malaga, Spain, June 2002. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. K. Arnold, J. Gosling, and D. Holmes. The Java Programming Language Third Edition. Addison-Wesley, Reading, MA, third edition, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. M. G. Assaad and G. T. Leavens. Alias-free parameters in C for better reasoning and optimization. Technical Report 01-11, Department of Computer Science, Iowa State University, Ames, Iowa, Nov. 2001.Google ScholarGoogle Scholar
  5. C. Barrett. Personal communication, Mar. 2004.Google ScholarGoogle Scholar
  6. V. Benzaken, G. Castagna, and A. Frisch. CDuce: An XML-centric general-purpose language. In Proceedings of the eighth ACM SIGPLAN international conference on Functional programming, pages 51--63. ACM Press, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. D. Blei, C. Harrelson, R. Jhala, R. Majumdar, G. C. Necula, S. P. Rahul, W. Weimer, and D. Weitz. Vampyre: A Proof Generating Theorem Prover. http://www.cs.ucla.edu/~rupak/Vampyre.Google ScholarGoogle Scholar
  8. D. G. Bobrow, K. Kahn, G. Kiczales, L. Masinter, M. Stefik, and F. Zdybel. CommonLoops: Merging Lisp and object-oriented programming. In Conference proceedings on Object-oriented programming systems, languages and applications, pages 17--29. ACM Press, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. T. Bray, J. Paoli, C. M. Sperberg-McQueen, E. Maler, and F. Yergeau. eXtensible Markup Language (XML) 1.0 (Third Edition). World Wide Web Consortium recommendation, http://www.w3.org/TR/REC-xml, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. G. Castagna. Covariance and contravariance: Conflict without a cause. ACM Transactions on Programming Languages and Systems, 17(3):431--447, Mar. 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. C. Chambers. Object-oriented multi-methods in Cecil. In O. L. Madsen, editor, Proceedings ECOOP '92, LNCS 615, pages 33--56. Springer-Verlag, June 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. C. Chambers. Predicate classes. In Proceedings of the 7th European Conference on Object-Oriented Programming, pages 268--296, July 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. C. Chambers. The Cecil language specification and rationale: Version 2.1. www.cs.washington.edu/research/projects/cecil/pubs/cecil-spec.html, Mar. 1997.Google ScholarGoogle Scholar
  14. C. Chambers and W. Chen. Efficient multiple and predicate dispatching. In Proceedings of the 14th ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pages 238--255, Denver, Colorado, 1999. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. C. Clifton. MultiJava: Design, implementation, and evaluation of a Java-compatible language supporting modular open classes and symmetric multiple dispatch. Technical Report 01-10, Department of Computer Science, Iowa State University, Ames, Iowa, Nov. 2001.Google ScholarGoogle Scholar
  16. C. Clifton, G. T. Leavens, C. Chambers, and T. Millstein. MultiJava: Modular open classes and symmetric multiple dispatch for Java. In OOPSLA 2000 Conference on Object-Oriented Programming, Systems, Languages, and Applications, pages 130--145, Minneapolis, Minnesota, Oct. 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. CVC Lite home page. http://verify.stanford.edu/CVCL.Google ScholarGoogle Scholar
  18. D. Detlefs, G. Nelson, and J. B. Saxe. Simplify: A theorem prover for program checking. Technical Report HPL-2003-148, HP Labs, 2003.Google ScholarGoogle Scholar
  19. S. Drossopoulou, S. Eisenbach, and D. Wragg. A fragment calculus - towards a model of separate compilation, linking and binary compatibility. In Logic in Computer Science, pages 147--156, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. M. Ernst, C. Kaplan, and C. Chambers. Predicate dispatching: A unified theory of dispatch. In E. Jul, editor, ECOOP '98-Object-Oriented Programming, LNCS 1445, pages 186--211. Springer, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. M. Fahndrich and R. DeLine. Adoption and focus: Practical linear types for imperative programming. In Proceedings of the ACM SIGPLAN 2002 Conference on Programming language design and implementation, pages 13--24. ACM Press, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. C. Flanagan, R. Joshi, X. Ou, and J. B. Saxe. Theorem proving using lazy proof explication. In CAV: International Conference on Computer Aided Verification, Boulder, Colorado, USA, July 2003.Google ScholarGoogle ScholarCross RefCross Ref
  23. J. S. Foster, T. Terauchi, and A. Aiken. Flow-sensitive type qualifiers. In Proceedings of the ACM SIGPLAN 2002 Conference on Programming language design and implementation, pages 1--12. ACM Press, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. R. P. Gabriel, J. L. White, and D. G. Bobrow. CLOS: Integrating Object-Oriented and Functional Programming. Commun. ACM, 34(9):28--38, Sept. 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. E. Gamma, R. Helm, R. E. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Massachusetts, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. V. Gapeyev and B. C. Pierce. Regular object types. In Proceedings of the 2003 European Conference on Object-Oriented Programming, LNCS 2743, Darmstadt, Germany, July 2003. Springer-Verlag.Google ScholarGoogle ScholarCross RefCross Ref
  27. D. Gay, P. Levis, R. von Behren, M. Welsh, E. Brewer, and D. Culler. The nesC language: A holistic approach to networked embedded systems. In Proceedings of the ACM SIGPLAN 2003 conference on Programming language design and implementation, pages 1--11. ACM Press, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. J. Gosling, B. Joy, G. Steele, and G. Bracha. The Java Language Specification Second Edition. The Java Series. Addison-Wesley, Boston, Mass., 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. R. Grimm. System Support for Pervasive Applications. Ph.D. dissertation, Department of Computer Science & Engineering, University of Washington, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. J. Hill, R. Szewczyk, A. Woo, S. Hollar, D. E. Culler, and K. S. J. Pister. System architecture directions for networked sensors. In Architectural Support for Programming Languages and Operating Systems (ASPLOS 2000), pages 93--104, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. J. G. Hosking, J. Hamer, and W. Mugridge. Integrating functional and object-oriented programming. In Proceedings of the 1990 TOOLS Pacific, pages 345--355, 1990.Google ScholarGoogle Scholar
  32. D. H. H. Ingalls. A simple technique for handling multiple polymorphism. In Conference proceedings on Object-oriented programming systems, languages and applications, pages 347--349. ACM Press, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. G. Kiczales, J. Lamping, A. Menhdhekar, C. Maeda, C. Lopes, J.-M. Loingtier, and J. Irwin. Aspect-oriented programming. In M. Aksoit and S. Matsuoka, editors, ECOOP '97 - Object-Oriented Programming 11th European Conference, Jyväskylä, Finland, LNCS 1241, pages 220--242. Springer-Verlag, New York, NY, June 1997.Google ScholarGoogle ScholarCross RefCross Ref
  34. G. T. Leavens and O. Antropova. ACL -Eliminating parameter aliasing with dynamic dispatch. Technical Report 98-08a, Department of Computer Science, Iowa State University, Ames, Iowa, Feb. 1999.Google ScholarGoogle Scholar
  35. K. Lee, A. LaMarca, and C. Chambers. HydroJ: Object-oriented pattern matching for evolvable distributed systems. In Proceedings of the 2003 ACM Conference on Object-Oriented Programming Systems, Languages, and Applications, Anaheim, CA, Oct. 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. J. Liu and A. C. Myers. JMatch: Iterable abstract pattern matching for Java. In V. Dahl and P. Wadler, editors, Practical Aspects of Declarative Languages, 5th International Symposium, volume 2562 of Lecture Notes in Computer Science, pages 110--127. Springer, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. T. Millstein. Reconciling Software Extensibility with Modular Program Reasoning. Ph.D. dissertation, Department of Computer Science & Engineering, University of Washington, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. T. Millstein, C. Bleckner, and C. Chambers. Modular typechecking for hierarchically extensible datatypes and functions. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP '02), volume 37(9) of ACM SIGPLAN Notices, pages 110--122, New York, NY, Sept. 2002. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. T. Millstein and C. Chambers. Modular statically typed multimethods. Information and Computation, 175(1):76--118, May 2002.Google ScholarGoogle ScholarCross RefCross Ref
  40. R. Milner, M. Tofte, R. Harper, and D. MacQueen. The Definition of Standard ML (Revised). The MIT Press, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. D. A. Moon. Object-oriented programming with Flavors. In Conference proceedings on Object-oriented programming systems, languages and applications, pages 1--8. ACM Press, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. MzScheme home page. http://www.plt-scheme.org/software/mzscheme.Google ScholarGoogle Scholar
  43. G. Nelson and D. C. Oppen. Simplification by cooperating decision procedures. ACM Trans. Program. Lang. Syst., 1(2):245--257, 1979. Google ScholarGoogle ScholarDigital LibraryDigital Library
  44. N. Nystrom, M. R. Clarkson, and A. C. Myers. Polyglot: An extensible compiler framework for Java. In Proceedings of CC 2003: 12'th International Conference on Compiler Construction. Springer-Verlag, Apr. 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  45. OCaml home page. http://www.ocaml.org.Google ScholarGoogle Scholar
  46. one.world home page. http://cs.nyu.edu/rgrimm/one.world.Google ScholarGoogle Scholar
  47. D. Orleans. Incremental programming with extensible decisions. In Proceedings of the 1st international conference on Aspect-oriented software development, pages 56--64. ACM Press, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  48. V. S. Pai, P. Druschel, and W. Zwaenepoel. Flash: An efficient and portable web server. In Proceedings of the 1999 USENIX Annual Technical Conference (USENIX-99), pages 199--212, Berkeley, CA, June 6-11 1999. USENIX Association. Google ScholarGoogle ScholarDigital LibraryDigital Library
  49. D. Remy and J. Vouillon. Objective ML: An effective object-oriented extension of ML. Theory and Practice of Object Systems, 4(1):27--52, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. The Scala language home page. http://lamp.epfl.ch/~odersky/scala.Google ScholarGoogle Scholar
  51. G. L. Steele Jr. Common Lisp: The Language, Second Edition. Digital Press, Bedford (MA), USA, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  52. B. Stroustrup. The C++ Programming Language: Third Edition. Addison-Wesley, Reading, Mass., 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  53. A. Stump, C. W. Barrett, and D. L. Dill. CVC: A Cooperating Validity Checker. In E. Brinksma and K. G. Larsen, editors, 14th International Conference on Computer Aided Verification (CAV), volume 2404 of Lecture Notes in Computer Science, pages 500--504. Springer-Verlag, 2002. Copenhagen, Denmark. Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. A. M. Ucko. Predicate Dispatching in the Common Lisp Object System. Technical Report 2001-006, MIT Artificial Intelligence Laboratory, June 2001.Google ScholarGoogle Scholar
  55. P. Wadler. Views: A way for pattern matching to cohabit with data abstraction. In Proceedings of the 14th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, pages 307--313. ACM Press, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  56. M. Welsh, D. Culler, and E. Brewer. SEDA: An Architecture for Well-Conditioned, Scalable Internet Services. In G. Ganger, editor, Proceedings of the 18th ACM Symposium on Operating Systems Principles, pages 230--243, 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Practical predicate dispatch

          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
            OOPSLA '04: Proceedings of the 19th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications
            October 2004
            462 pages
            ISBN:1581138318
            DOI:10.1145/1028976
            • cover image ACM SIGPLAN Notices
              ACM SIGPLAN Notices  Volume 39, Issue 10
              OOPSLA '04
              October 2004
              448 pages
              ISSN:0362-1340
              EISSN:1558-1160
              DOI:10.1145/1035292
              Issue’s Table of Contents

            Copyright © 2004 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: 1 October 2004

            Permissions

            Request permissions about this article.

            Request Permissions

            Check for updates

            Qualifiers

            • Article

            Acceptance Rates

            Overall Acceptance Rate268of1,244submissions,22%

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader