Abstract
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 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 the practical utility of this language feature.
We describe JPred, a backward-compatible extension to Java supporting predicate dispatch. While prior languages with predicate dispatch have been extensions to toy or nonmainstream 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 typechecking 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 informally, we present an extension to Featherweight Java that formalizes the language and its modular type system, which we have proven sound. Finally, we discuss two case studies that illustrate the practical utility of JPred, including its use in the detection of several errors.
- Abelson, H., Dybvig, R. K., Haynes, C. T., Rozas, G. J., IV, N. I. A., Friedman, D. P., Kohlbecker, E., Steele Jr., G. L., Bartley, D. H., Halstead, R., Oxley, D., Sussman, G. J., Brooks, G., Hanson, C., Pitman, K. M., and Wand, M. 1998. Revised report on the algorithmic language Scheme. Higher-Order Symbolic Comput. 11, 1, 7--105. Google Scholar
Digital Library
- Agrawal, R., DeMichiel, L. G., and Lindsay, B. G. 1991. Static type checking of multi-methods. In Proceedings of the (OOPSLA'91) Conference on Object-Oriented Programming Systems, Languages and Applications, 113--128. Google Scholar
Digital Library
- Arnold, K., Gosling, J., and Holmes, D. 2005. The Java Programming Language, 4th ed. Prentice Hall. Google Scholar
Digital Library
- Assaad, M. G. and Leavens, G. T. 2001. Alias-Free parameters in C for better reasoning and optimization. Tech. Rep. 01-11, Department of Computer Science, Iowa State University, Ames, Iowa. November.Google Scholar
- Barrett, C. and Berezin, S. 2004. CVC Lite: A new implementation of the cooperating validity checker. In Proceedings of the 16th International Conference on Computer Aided Verification (CAV'04), R. Alur and D. A. Peled, Eds. Lecture Notes in Computer Science, vol. 3114. Springer, 515--518.Google Scholar
- Baumgartner, G., Jansche, M., and Laufer, K. revised March 2002. Half & Half: Multiple dispatch and retroactive abstraction for Java. Tech. rep. OSU-CISRC-5/01-TR08, Department of Computer and Information Science, The Ohio State University.Google Scholar
- Benzaken, V., Castagna, G., and Frisch, A. 2003. CDuce: An XML-centric general-purpose language. In Proceedings of the 8th ACM SIGPLAN International Conference on Functional Programming. ACM Press, 51--63. Google Scholar
Digital Library
- Bobrow, D. G., Kahn, K., Kiczales, G., Masinter, L., Stefik, M., and Zdybel, F. 1986. CommonLoops: Merging Lisp and object-oriented programming. In Proceedings of the Conference on Object-oriented Programming Systems, Languages and Applications. ACM Press, 17--29. Google Scholar
Digital Library
- Boyland, J. and Castagna, G. 1997. Parasitic methods: Implementation of multi-methods for Java. In Proceedings of the OOPSLA'97. ACM SIGPLAN Not. 32, 10, 66--76. Google Scholar
Digital Library
- Bray, T., Paoli, J., Sperberg-McQueen, C. M., Maler, E., and Yergeau, F. 2006. eXtensible markup language (XML) 1.0 (4th Edition). World Wide Web Consortium recommendation, http://www.w3.org/TR/REC-xml.Google Scholar
- Castagna, G. 1995. Covariance and contravariance: Conflict without a cause. ACM Trans. Program. Lang. Syst. 17, 3, 431--447. Google Scholar
Digital Library
- Castagna, G. 1997. Object-Oriented Programming: A Unified Foundation. Progress in Theoretical Computer Science. Birkhauser, Boston. Google Scholar
Digital Library
- Castagna, G., Ghelli, G., and Longo, G. 1995. A calculus for overloaded functions with subtyping. Inf. Comput. 117, 1, 115--135. Google Scholar
Digital Library
- Chambers, C. 1992. Object-Oriented multi-methods in Cecil. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP'92), O. L. Madsen, Ed. LNCS 615. Springer-Verlag, 33--56. Google Scholar
Digital Library
- Chambers, C. 1993. Predicate classes. In Proceedings of the 7th European Conference on Object-Oriented Programming, 268--296. Google Scholar
Digital Library
- Chambers, C. 1997. The Cecil language specification and rationale: Version 2.1. www.cs.washington.edu/research/projects/cecil/pubs/cecil-spec.html.Google Scholar
- Chambers, C. and Chen, W. 1999. Efficient multiple and predicate dispatching. In Proceedings of the 14th ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications. ACM Press, 238--255. Google Scholar
Digital Library
- Clifton, C. 2001. MultiJava: Design, implementation, and evaluation of a Java-compatible language supporting modular open classes and symmetric multiple dispatch. Tech. rep. 01-10, Department of Computer Science, Iowa State University, Ames, Iowa. November.Google Scholar
- Clifton, C., Leavens, G. T., Chambers, C., and Millstein, T. 2000. MultiJava: Modular open classes and symmetric multiple dispatch for Java. In Proceedings of the Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA'00). ACM SIGPLAN Notices, 35, 10, 130--145. Google Scholar
Digital Library
- Clifton, C., Millstein, T., Leavens, G. T., and Chambers, C. 2006. Multijava: Design rationale, compiler implementation, and applications. ACM Trans. Program. Lang. Syst. 28, 3, 517--575. Google Scholar
Digital Library
- CVC3. 2009. The CVC3 home page. http://www.cs.nyu.edu/acsys/cvc3.Google Scholar
- Detlefs, D., Nelson, G., and Saxe, J. B. 2005. Simplify: A theorem prover for program checking. J. ACM 52, 3, 365--473. Google Scholar
Digital Library
- Eclipse. 2007. Eclipse home page. http://www.eclipse.org.Google Scholar
- Emir, B., Odersky, M., and Williams, J. 2007. Matching objects with patterns. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP), E. Ernst, Ed. Lecture Notes in Computer Science, vol. 4609. Springer, 273--298. Google Scholar
Digital Library
- Ernst, M., Kaplan, C., and Chambers, C. 1998. Predicate dispatching: A unified theory of dispatch. In Proceedings of the European Conference on Object-Oriented Programming (ECOOP'98), E. Jul, Ed. Lecture Notes in Computer Science, vol. 1445. Springer, 186--211. Google Scholar
Digital Library
- Flanagan, C., Joshi, R., Ou, X., and Saxe, J. B. 2003. Theorem proving using lazy proof explication. In the International Conference on Computer Aided Verification (CAV).Google Scholar
- Frost, C. and Millstein, T. 2005. Featherweight JPred. Tech. rep. CSD-TR-050038, UCLA Computer Science Department. ftp://ftp.cs.ucla.edu/tech-report/2005-reports/050038.pdf.Google Scholar
- Frost, C. and Millstein, T. 2006. Modularly typesafe interface dispatch in JPred. In the International Workshop on Foundations and Developments of Object-Oriented Languages(FOOL/WOOD).Google Scholar
- Gabriel, R. P., White, J. L., and Bobrow, D. G. 1991. CLOS: Integrating object-oriented and functional programming. Commun. ACM 34, 9, 28--38. Google Scholar
Digital Library
- Gamma, E., Helm, R., Johnson, R. E., and Vlissides, J. 1995. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, MA. Google Scholar
Digital Library
- Gapeyev, V. and Pierce, B. C. 2003. Regular object types. In Proceedings of the European Conference on Object-Oriented Programming. Lecture Notes in Computer Science, vol. 2743. Springer.Google Scholar
- Gay, D., Levis, P., von Behren, R., Welsh, M., Brewer, E., and Culler, D. 2003. The NesC language: A holistic approach to networked embedded systems. In Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation. ACM Press, 1--11. Google Scholar
Digital Library
- Gosling, J., Joy, B., Steele, G., and Bracha, G. 2005. The Java Language Specification 3rd Ed. Prentice Hall. Google Scholar
Digital Library
- Grimm, R. 2002. System support for pervasive applications. Ph.D. thesis, Department of Computer Science and Engineering, University of Washington. Google Scholar
Digital Library
- Grimm, R., Davis, J., Lemar, E., Macbeth, A., Swanson, S., Anderson, T., Bershad, B., Borriello, G., Gribble, S., and Wetherall, D. 2004. System support for pervasive applications. ACM Trans. Comput. Syst. 22, 4, 421--486. Google Scholar
Digital Library
- Hill, J., Szewczyk, R., Woo, A., Hollar, S., Culler, D. E., and Pister, K. S. J. 2000. System architecture directions for networked sensors. In Proceedings of the Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS'00). 93--104. Google Scholar
Digital Library
- Hosking, J. G., Hamer, J., and Mugridge, W. 1990. Integrating functional and object-oriented programming. In Proceedings of the International Conference on Technology of Obeject-Oriented Languages and Systems TOOLS Pacific, 345--355.Google Scholar
- Igarashi, A., Pierce, B. C., and Wadler, P. 2001. Featherweight Java: a minimal core calculus for Java and GJ. ACM Trans. Program, Lang. Syst. 23, 3, 396--450. Google Scholar
Digital Library
- Ingalls, D. H. H. 1986. A simple technique for handling multiple polymorphism. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages and Applications. ACM Press, 347--349. Google Scholar
Digital Library
- Kiczales, G., Lamping, J., Menhdhekar, A., Maeda, C., Lopes, C., Loingtier, J.-M., and Irwin, J. 1997. Aspect-Oriented programming. In Proceedings of the 11th European Conference on Object-Oriented (ECOOP'97), M. Akşit and S. Matsuoka, Eds. Lecture Notes on Computer Science, vol. 1241. Springer, 220--242.Google Scholar
- Leavens, G. T. and Antropova, O. 1999. ACL — Eliminating parameter aliasing with dynamic dispatch. Tech. rep. 98-08a, Department of Computer Science, Iowa State University, Ames, Iowa. February.Google Scholar
- Lee, K., LaMarca, A., and Chambers, C. 2003. HydroJ: Object-Oriented pattern matching for evolvable distributed systems. In Proceedings of the ACM Conference on Object-Oriented Programming Systems, Languages, and Applications. Google Scholar
Digital Library
- Liu, J. and Myers, A. C. 2003. JMatch: Iterable abstract pattern matching for Java. In Proceedings of the International Symposium on Practical Aspects of Declarative Languages (PADL), V. Dahl and P. Wadler, Eds. Lecture Notes in Computer Science, vol. 2562. Springer, 110--127. Google Scholar
Digital Library
- Millstein, T. 2003. Reconciling software extensibility with modular program reasoning. Ph.D. thesis, Department of Computer Science and Engineering, University of Washington. Google Scholar
Digital Library
- Millstein, T. 2004. Practical predicate dispatch. In Proceedings of the Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA'04). Google Scholar
Digital Library
- Millstein, T., Bleckner, C., and Chambers, C. 2002. Modular typechecking for hierarchically extensible datatypes and functions. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP'02). ACM SIGPLAN Not. 37, 9, 110--122. Google Scholar
Digital Library
- Millstein, T., Bleckner, C., and Chambers, C. 2004. Modular typechecking for hierarchically extensible datatypes and functions. ACM Trans. Program. Lang. Syst. 26, 5, 836--889. Google Scholar
Digital Library
- Millstein, T. and Chambers, C. 2002. Modular statically typed multimethods. Inf. Comput. 175, 1, 76--118.Google Scholar
Cross Ref
- Milner, R., Tofte, M., Harper, R., and MacQueen, D. 1997. The Definition of Standard ML (Revised). The MIT Press. Google Scholar
Digital Library
- Moon, D. A. 1986. Object-Oriented programming with Flavors. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages and Applications. ACM Press, 1--8. Google Scholar
Digital Library
- Nelson, G. and Oppen, D. C. 1979. Simplification by cooperating decision procedures. ACM Trans. Program. Lang. Syst. 1, 2, 245--257. Google Scholar
Digital Library
- Nystrom, N., Clarkson, M. R., and Myers, A. C. 2003. Polyglot: An extensible compiler framework for Java. In Proceedings of the 12th International Conference on Compiler Construction (CC). Springer. Google Scholar
Digital Library
- oneworld. 2008. one.world home page. http://cs.nyu.edu/rgrimm/one.world.Google Scholar
- Orleans, D. 2002. Incremental programming with extensible decisions. In Proceedings of the 1st International Conference on Aspect-Oriented Software Development. ACM Press, 56--64. Google Scholar
Digital Library
- Pai, V. S., Druschel, P., and Zwaenepoel, W. 1999. Flash: An efficient and portable Web server. In Proceedings of the USENIX Annual Technical Conference (USENIX-99). USENIX Association, 199--212. Google Scholar
Digital Library
- Polyglot for Java 5. Polyglot for Java 5 homepage. http://www.cs.ucla.edu/~milanst/projects/polyglot5.Google Scholar
- Rémy, D. and Vouillon, J. 1998. Objective ML: An effective object-oriented extension of ML. Theory Practice Object Syst. 4, 1, 27--52. Google Scholar
Digital Library
- Richard, A. and Lhotak, O. 2008. OOMatch: Pattern matching as dispatch in Java. In International Workshop on Foundations of Object-Oriented Languages.Google Scholar
- Salcianu, A. and Rinard, M. 2005. Purity and side effect analysis for Java programs. In Proceedings of the 6th International Conference on Verification, Model Checking and Abstract Interpretation. Google Scholar
Digital Library
- Steele Jr., G. L. 1990. Common Lisp: The Language, 2nd Ed. Digital Press, Bedford, MA. Google Scholar
Digital Library
- Stroustrup, B. 1997. The C++ Programming Language: Third Edition. Addison-Wesley, Reading, MA. Google Scholar
Digital Library
- Ucko, A. M. 2001. Predicate dispatching in the common lisp object system. Tech. rep. 2001-006, MIT Artificial Intelligence Laboratory.Google Scholar
- Welsh, M., Culler, D., and Brewer, E. 2001. SEDA: An Architecture for well-conditioned, scalable internet services. In Proceedings of the 18th ACM Symposium on Operating Systems Principles, G. Ganger, Ed. 230--243. Google Scholar
Digital Library
- Wright, A. K. and Felleisen, M. 1994. A syntactic approach to type soundness. Inf. Comput. 115, 1, 38--94. Google Scholar
Digital Library
Index Terms
Expressive and modular predicate dispatch for Java
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 ...
Practical predicate dispatch
OOPSLA '04: Proceedings of the 19th annual ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications<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 ...
Modular typechecking for hierarchically extensible datatypes and functions
One promising approach for adding object-oriented (OO) facilities to functional languages like ML is to generalize the existing datatype and function constructs to be hierarchical and extensible, so that datatype variants simulate classes and function ...






Comments