Skip to main content

The VISITOR Pattern as a Reusable, Generic, Type-Safe Component

Oliveira, Bruno, Wang, Meng, Gibbons, Jeremy (2008) The VISITOR Pattern as a Reusable, Generic, Type-Safe Component. In: Proceedings of the 23rd ACM SIGPLAN conference on Object-oriented programming systems languages and applications. .

PDF - Author's Accepted Manuscript
Download (226kB) Preview
Official URL


The VISITOR design pattern shows how to separate the structure of an object hierarchy from the behaviour of traversals over that hierarchy. The pattern is very flexible; this very flexibility makes it difficult to capture the pattern formally. We show how to capture the essence of the VISITOR pattern as a reusable software library, by using advanced type system features appearing in modern object-oriented languages such as Scala. We preserve type-safety statically: no reflection or similar mechanisms are used. The library is generic, in two senses: by types (the traversal return type and the object hierarchy shape) and by strategy (internal versus external control, imperative versus functional behaviour, orthogonal aspects such as tracing and memoisation). Finally, we propose a generalised datatype-like notation, providing a convenient functional decomposition style in object-oriented languages.

Item Type: Conference or workshop item (Paper)
Subjects: Q Science > QA Mathematics (inc Computing science) > QA 75 Electronic computers. Computer science
Q Science > QA Mathematics (inc Computing science) > QA 76 Software, computer programming,
Divisions: Faculties > Sciences > School of Computing > Programming Languages and Systems Group
Depositing User: Meng Wang
Date Deposited: 28 Feb 2015 16:27 UTC
Last Modified: 29 May 2019 14:17 UTC
Resource URI: (The current URI for this page, for reference purposes)
  • Depositors only (login required):


Downloads per month over past year