Search

External Dispatch: Yet Another Object-Oriented Single and Multiple Dispatch Mechanism

By: Miguel Oliveira e Silva

Abstract

Although multiple dispatch properly solves difficult programming problems such as binary methods, the large majority of existing object-oriented programming languages still don’t support it. The few languages that provide such a mechanism do so in ways that either lie outside an object-oriented modular construct (class), or possess some other limitations, such as arbitrarily choosing one of the dispatch object types as the repository for dispatch methods. This article presents a new object-oriented language mechanism for single and multiple dispatch. As a proof of concept, we will use Java as the base language. This mechanism is compatible with existing object-oriented language constructs, and provides a simple, expressive, and universal dispatch tool. Our proposal introduces a new object-oriented external dispatch mechanism, which complements the traditional object-oriented internal single dispatch mechanism. This new mechanism is applicable not only to multiple dispatch, but can also be used as an alternative to decorators and some creational design patterns. A more complete realization for external dispatch motivated the definition of a new singleton language mechanism that is also presented.

Keywords

multiple dispatch, single dispatch, external dispatch, object-oriented programming languages, multimethods, binary methods, type covariance, encapsulation, modularity, static typechecking, subtyping, inheritance, mixins, decorator design pattern, creational design patterns, singleton, Java

Cite as:

Miguel Oliveira e Silva, “External Dispatch: Yet Another Object-Oriented Single and Multiple Dispatch Mechanism”, Journal of Object Technology, Volume 16, no. 2 (April 2017), pp. 1:1-18, doi:10.5381/jot.2017.16.2.a1.

PDF | DOI | BiBTeX | Tweet this | Post to CiteULike | Share on LinkedIn