ABSTRACT
In object systems, classes take the role of modules, and interfaces consist of methods. Because methods are encapsulated in objects, interfaces in object systems do not allow abstracting over where methods are implemented. This implies that any change to the implementation structure may cause a rippling effect. Sometimes this unduly restricts the scope of software evolution, in particular for methods with multiple parameters where there is no clear owner. We propose a simple scheme where symmetric methods may be defined in the classes of any of their parameters. This allows client code to be oblivious of what class contains a method implementation, and therefore immune against it changing. When combined with multiple dynamic dispatch, this scheme allows for modular extensibility (but not modular type-checking) where a method defined in one class is overridden by a method defined in a class that is not its subtype. In this paper, we illustrate the scheme by extending a core calculus of class-based languages with these symmetric encapsulated multi-methods, and prove the result sound.
- Allen, Chase, Hallett, Luchangco, Maessen, Ryu, Steele, and Tobin-Hochstadt. The Fortress Language Specification. Version 1.0. Sun Microsystems, 2008.Google Scholar
- E. Allen, J. J. Hallett, V. Luchangco, S. Ryu, and J. Guy L. Steele. Modular multiple dispatch with multiple inheritance. In SAC '07: Proceedings of the 2007 ACM symposium on Applied computing, pages 1117--1121, New York, NY, USA, 2007. ACM. Google ScholarDigital Library
- D. G. Bobrow, L. G. DeMichiel, R. P. Gabriel, S. E. Keene, G. Kiczales, and D. A. Moon. Common lisp object system specification. SIGPLAN Not., 23(SI):1--142, 1988. Google ScholarDigital Library
- F. Bourdoncle and S. Merz. Type checking higher-order polymorphic multi-methods. In POPL '97: Proceedings of the 24th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 302--315, New York, NY, USA, 1997. ACM. Google ScholarDigital Library
- J. Boyland and G. Castagna. Parasitic methods: an implementation of multi-methods for java. In OOPSLA '97: Proceedings of the 12th ACM SIGPLAN conference on Object-oriented programming, systems, languages, and applications, pages 66--76, New York, NY, USA, 1997. ACM. Google ScholarDigital Library
- K. Bruce, L. Cardelli, G. Castagna, G. T. Leavens, and B. Pierce. On binary methods. Theor. Pract. Object Syst., 1(3):221--242, 1995. Google ScholarDigital Library
- G. Castagna. Covariance and contravariance: conflict without a cause. ACM Trans. Program. Lang. Syst., 17(3):431--447, 1995. Google ScholarDigital Library
- G. Castagna, G. Ghelli, and G. Longo. A calculus for overloaded functions with subtyping. Information and Computation, 117(1):115--135, 15 Feb. 1995. Google ScholarDigital Library
- C. Clifton, T. Millstein, G. T. Leavens, and C. Chambers. Multijava: Design rationale, compiler implementation, and applications. ACM Trans. Program. Lang. Syst., 28(3):517--575, 2006. Google ScholarDigital Library
- B. Foote, R. E. Johnson, and J. Noble. Efficient multimethods in a single dispatch language. In ECOOP, pages 337--361, 2005. Google ScholarDigital Library
- C. Frost and T. Millstein. Modularly typesafe interface dispatch in jpred. In The 2006 International Workshop on Foundations and Developments of Object-Oriented Languages (FOOL/WOOD '06), January 2006.Google Scholar
- W. Harrison, D. Lievens, and T. Walsh. Continuum/j language specification. Technical report, Trinity College Dublin, 2008.Google Scholar
- W. Harrison and H. Ossher. Subject-oriented programming: a critique of pure objects. SIGPLAN Not., 28(10):411--428, 1993. Google ScholarDigital Library
- A. Igarashi, B. Pierce, and P. Wadler. Featherweight Java: A minimal core calculus for Java and GJ. TOPLAS, 23(3):396--459, May 2001. Google ScholarDigital Library
- D. Lievens and W. Harrison. Symmetric encapsulated multi-methods. Technical report, Trinity College Dublin, 2008.Google Scholar
- T. Millstein, M. Reay, and C. Chambers. Relaxed multijava: balancing extensibility and modular typechecking. In OOPSLA '03: Proceedings of the 18th annual ACM SIGPLAN conference on Object-oriented programing, systems, languages, and applications, pages 224--240, New York, NY, USA, 2003. ACM. Google ScholarDigital Library
- T. D. Millstein and C. Chambers. Modular statically typed multimethods. In ECOOP '99: Proceedings of the 13th European Conference on Object-Oriented Programming, pages 279--303, London, UK, 1999. Springer-Verlag. Google ScholarDigital Library
- D. L. Parnas. On the criteria to be used in decomposing systems into modules. Commun. ACM, 15(12):1053--1058, 1972. Google ScholarDigital Library
- P. Pirkelbauer, Y. Solodkyy, and B. Stroustrup. Open multi-methods for c++. In GPCE '07: Proceedings of the 6th international conference on Generative programming and component engineering, pages 123--134, New York, NY, USA, 2007. ACM. Google ScholarDigital Library
Index Terms
Symmetric encapsulated multi-methods to abstract over application structure
Recommendations
Typeless programming in Java 5.0 with wildcards
PPPJ '07: Proceedings of the 5th international symposium on Principles and practice of programming in JavaWith the introduction of Java 5.0 [8] the type system has been extended by parameterized types, type variables, type terms, and wildcards. As a result very complex types can arise. The term Vector<? super Vector<? extends List<Integer>>> is for example ...
Typeless programming in Java 5.0
PPPJ '06: Proceedings of the 4th international symposium on Principles and practice of programming in JavaWith the introduction of Java 5.0 [9] the type system has been extended by parameterized types, type variables, type terms, and wildcards. As a result very complex types can arise. The termVector<Vector<AbstractList<Integer>>>is for example a correct ...
Well-typings for Javaλ
PPPJ '11: Proceedings of the 9th International Conference on Principles and Practice of Programming in JavaIn the last decade Java has been extended by some features, which are well-known from functional programming languages. In Java 8 the language will be expanded by closures (λ-expressions).
In our contribution we give a formal definition for an abstract ...
Comments