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.
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.