Loading…

A Type-theoretic Reconstruction of the Visitor Pattern

In object-oriented languages, the Visitor pattern can be used to traverse tree-like data structures: a visitor object contains some operations, and the data structure objects allow themselves to be traversed by accepting visitors. In the polymorphic lambda calculus (System F), tree-like data structu...

Full description

Saved in:
Bibliographic Details
Published in:Electronic notes in theoretical computer science 2006-05, Vol.155, p.309-329
Main Authors: Buchlovsky, Peter, Thielecke, Hayo
Format: Article
Language:English
Subjects:
Citations: Items that this one cites
Items that cite this one
Online Access:Get full text
Tags: Add Tag
No Tags, Be the first to tag this record!
Description
Summary:In object-oriented languages, the Visitor pattern can be used to traverse tree-like data structures: a visitor object contains some operations, and the data structure objects allow themselves to be traversed by accepting visitors. In the polymorphic lambda calculus (System F), tree-like data structures can be encoded as polymorphic higher-order functions. In this paper, we reconstruct the Visitor pattern from the polymorphic encoding by way of generics in Java. We sketch how the quantified types in the polymorphic encoding can guide reasoning about visitors in general.
ISSN:1571-0661
1571-0661
DOI:10.1016/j.entcs.2005.11.061