Affiliation:
1. University of Oxford, Oxford, United Kingdom
Abstract
The V
ISITOR
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 as anything more formal than prose, pictures and prototypes.
We show how to capture the essence of the V
ISITOR
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 and modularly
: no reflection or similar mechanisms are used and modules can be independently compiled. The library is
generic
, in two senses: not only is it parametrised by both the return type and the shape of the object hierarchy, but also it allows a number of implementation choices (internal versus external control, imperative versus functional behaviour, orthogonal aspects such as tracing and memoisation) to be specified by parameters rather than fixed in early design decisions. Finally, we propose a generalised
datatype
-like notation,on top of our visitor library: this provides a convenient functional decomposition style in object-oriented languages.
Publisher
Association for Computing Machinery (ACM)
Subject
Computer Graphics and Computer-Aided Design,Software
Cited by
7 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献