The emph{Visitor design pattern allows the encapsulation of polymorphic behavior outside the class hierarchy on which it operates. A common application of emph{Visitor is the encapsulation of tree traversals. Unfortunately, visitors resist composition and allow little traversal control. To remove these limitations, we introduce visitor emph{combinators. These are implementations of the visitor interface that can be used to emph{compose new visitors from given ones. The set of combinators we propose includes emph{traversal combinators that can be used to obtain full traversal control. A clean separation can be made between the generic parts of the combinator set and the parts that are specific to a particular class hierarchy. The generic parts form a reusable framework. The specific parts can be generated from a (tree) grammar. Due to this separation, programming with visitor combinators becomes a form of emph{generic programming with significant reuse of (visitor) code.

Automatic Programming (acm D.1.2), Object-oriented Programming (acm D.1.5), Coding Tools and Techniques (acm D.2.3), Tools (acm D.2.1.3), Processors (acm D.3.4), DATA STORAGE REPRESENTATIONS (acm E.2)
Software Engineering [SEN]

Visser, J.M.W. (2001). Visitor combination and traversal control. Software Engineering [SEN]. CWI.