Visitor pattern (source code)

= Visitor pattern

Separate operations from a relatively stable hierarchy of element classes. An element's accept operation calls the visitor overload appropriate to its own concrete type, combining virtual dispatch with static overload selection to obtain <double dispatch>. New operations can be added as visitors; adding an element type generally requires extending the visitor interface and existing visitors.