Re:Software Design Patterns Are Not Goals, They Are Tools
by emodendroket on Friday May 20, 2016 @09:07AM
(#11737432)
I'm not sure I'm following what you describe. Like an extension method or mix-in?
Re:Software Design Patterns Are Not Goals, They Are Tools
by Munksgaard on Friday May 20, 2016 @03:15AM
(#11736035)
So pattern matching?
Re:Software Design Patterns Are Not Goals, They Are Tools
by munificent on Wednesday May 25, 2016 @01:30AM
(#11767832)
Sort of. It's a way to emulate a simple subset of pattern matching in languages that lack it.
It gives you a way to "add a method" to a set of classes without actually stuffing them in the class definitions themselves.
In practice, most visitor patterns are used with AST classes or other types that are stored in a tree-like fashion, but that's coincidence. The visitor pattern itself is really about using virtual dispatch to avoid an ugly and non-type-safe type switch.