Re:Grim C++ Tales from the Crypt: The Visitor Pattern (2017)
by int_19h on Wednesday March 06, 2019 @04:49PM
(#19323212)
Have you considered that multiple dispatch is obscure because it requires jumping through such hoops to implement in most mainstream languages, rather than because of its lack of utility?
Re:Grim C++ Tales from the Crypt: The Visitor Pattern (2017)
by kazinator on Wednesday March 06, 2019 @03:20PM
(#19322373)
The short answer is that the existence of multiple dispatch isn't motivated by the visitor pattern.
Moreover, multiple dispatch isn't obscure at all.
C++ has it, but only statically, for instance, in the form of overloaded functions. C++ chooses a function overload by looking at the types of all parameters and arguments.
Multiple dispatch is similar, but the run-time types of the arguments are used.
This is broadly applicable in making all sorts of situations nicer.
Re:Grim C++ Tales from the Crypt: The Visitor Pattern (2017)
by bstamour on Wednesday March 06, 2019 @01:11PM
(#19321094)
Why have functions and control structures when we can just jmp?
Re:Grim C++ Tales from the Crypt: The Visitor Pattern (2017)
by geezerjay on Wednesday March 06, 2019 @04:27PM
(#19322984)
That's a disingenuous comparison. Functions are used pervasively, but even the visitor pattern isn't used very often.
Re:Grim C++ Tales from the Crypt: The Visitor Pattern (2017)
by bstamour on Thursday March 07, 2019 @09:11AM
(#19328094)
But in languages that support multiple dispatch at the language level, they're just another way of writing polymorphic functions. They're not just a niche feature. When you don't have to write all of the ceremony of the visitor pattern, it's easier to use visitors everywhere without thinking about them.
Some of these complains are at best very misguided.