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.
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- K. Arnold, J. Gosling, and D. Holmes. The Java Programming Language Third Edition. Addison-Wesley, Reading, MA, third edition, 2000. Google ScholarDigital Library
- 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 Scholar
- C. Barrett. Personal communication, Mar. 2004.Google Scholar
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- G. Castagna. Covariance and contravariance: Conflict without a cause. ACM Transactions on Programming Languages and Systems, 17(3):431--447, Mar. 1995. Google ScholarDigital Library
- 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 ScholarDigital Library
- C. Chambers. Predicate classes. In Proceedings of the 7th European Conference on Object-Oriented Programming, pages 268--296, July 1993. Google ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- CVC Lite home page. http://verify.stanford.edu/CVCL.Google Scholar
- D. Detlefs, G. Nelson, and J. B. Saxe. Simplify: A theorem prover for program checking. Technical Report HPL-2003-148, HP Labs, 2003.Google Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarCross Ref
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- E. Gamma, R. Helm, R. E. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Massachusetts, 1995. Google ScholarDigital Library
- 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 ScholarCross Ref
- 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 ScholarDigital Library
- J. Gosling, B. Joy, G. Steele, and G. Bracha. The Java Language Specification Second Edition. The Java Series. Addison-Wesley, Boston, Mass., 2000. Google ScholarDigital Library
- R. Grimm. System Support for Pervasive Applications. Ph.D. dissertation, Department of Computer Science & Engineering, University of Washington, 2002. Google ScholarDigital Library
- 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 ScholarDigital Library
- 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 Scholar
- 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 ScholarDigital Library
- 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 ScholarCross Ref
- 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 Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- T. Millstein. Reconciling Software Extensibility with Modular Program Reasoning. Ph.D. dissertation, Department of Computer Science & Engineering, University of Washington, 2003. Google ScholarDigital Library
- 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 ScholarDigital Library
- T. Millstein and C. Chambers. Modular statically typed multimethods. Information and Computation, 175(1):76--118, May 2002.Google ScholarCross Ref
- R. Milner, M. Tofte, R. Harper, and D. MacQueen. The Definition of Standard ML (Revised). The MIT Press, 1997. Google ScholarDigital Library
- 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 ScholarDigital Library
- MzScheme home page. http://www.plt-scheme.org/software/mzscheme.Google Scholar
- G. Nelson and D. C. Oppen. Simplification by cooperating decision procedures. ACM Trans. Program. Lang. Syst., 1(2):245--257, 1979. Google ScholarDigital Library
- 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 ScholarDigital Library
- OCaml home page. http://www.ocaml.org.Google Scholar
- one.world home page. http://cs.nyu.edu/rgrimm/one.world.Google Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- 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 ScholarDigital Library
- The Scala language home page. http://lamp.epfl.ch/~odersky/scala.Google Scholar
- G. L. Steele Jr. Common Lisp: The Language, Second Edition. Digital Press, Bedford (MA), USA, 1990. Google ScholarDigital Library
- B. Stroustrup. The C++ Programming Language: Third Edition. Addison-Wesley, Reading, Mass., 1997. Google ScholarDigital Library
- 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 ScholarDigital Library
- A. M. Ucko. Predicate Dispatching in the Common Lisp Object System. Technical Report 2001-006, MIT Artificial Intelligence Laboratory, June 2001.Google Scholar
- 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 ScholarDigital Library
- 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 ScholarDigital Library
Index Terms
- Practical predicate dispatch
Recommendations
Practical predicate dispatch
OOPSLA '04<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 ...
Expressive and modular predicate dispatch for Java
Predicate dispatch 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 ...
Predicate-C: an efficient and generic runtime system for predicate dispatch
ICOOOLPS '11: Proceedings of the 6th Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and SystemsDynamically typed languages like Ruby [19] recently gained a growing popularity due to the simplification of unforeseen software extensibility. Extensibility is typically driven by method dispatch which in turn uses the type system to classify objects. ...
Comments