3 ms·
The double-indirection of the visitor pattern is unnecessary in a language with pattern matching. I mean sure, it's just syntax, just sugar - but readability is
by lmm 12y ago
The double-indirection of the visitor pattern is unnecessary in a language with pattern matching. I mean sure, it's just syntax, just sugar - but readability is important. As the saying goes, a design pattern is a structured way of working around a language deficiency.
- king_magic 12y agoI agree, but I'd argue that double-indirection isn't really a defining characteristic of the visitor pattern. In fact, I'd argue that the visitor pattern is really one of the most "functional" patterns there is.
- TillE 12y agoQuite. It should be obvious how to implement it using std::function and lambdas in C++, for example. Having a bunch of polymorphic classes is an ugly implementation detail, not the essence of the pattern.
- deleted 12y ago[deleted]
- j_jochem 12y agoFrom what they taught me at software engineering 101, double dispatch is exactly the point of the visitor pattern. If your instance of Visitor lacks double dispatch, that means it's just a very complicated way of performing external iteration on Composites.