@MISC{VanDrunen03visitor-orientedprogramming, author = {Thomas VanDrunen and Jens Palsberg}, title = {Visitor-Oriented Programming}, year = {2003} }
Bookmark
OpenURL
Abstract
Multiple dispatching and the visitor pattern are approaches to making object-oriented programs more extensible. Both have a flavor of pattern matching, thereby moving objectoriented programming closer to functional programming. The key idea of these approaches can be crystallized as a notion of visitor which lies between functions and objects. Can this idea be developed into a new form of visitor-oriented programming which combines the best of functional and object-oriented programming? As a first step, we present a visitor calculus in which each value is a visitor and every visitor call uses double dispatching. We illustrate the relationships to other paradigms by translating the lambda-calculus to the visitor calculus, and the visitor calculus to Java. Our calculus forms the core of a language in which we have programmed the translation of the lambda-calculus to the visitor calculus itself. To demonstrate the expressiveness of visitors, we show the translation in four versions that use smaller and smaller subsets of the language. Along the way, we present correctness proofs and examples of running an implementation of our language.