Get the latest tech news
A polyglot's guide to multiple-dispatch (2016)
This is the first article in a series dedicated to multiple dispatch - an advanced abstraction technique available to programmers out-of-the-box in some languages, and implementable in others. This first post in the series presents the technique and explains the problem it intends to solve.
Showing how multiple dispatch is implemented in a language that doesn't support it natively is important, in my opinion, as it lets us understand the issue on a deeper level. This function may have a whole bunch of special cases inside for different combinations of shapes it knows how to do easily, before it resorts to some heavy-handed generic polygon intersection approach. One of the most notable experts to tackle the beast is Andrei Alexandrescu, who dedicated chapter 11 of "Modern C++ Design" to this problem, implementing all kinds of automated solutions based on heavy template metaprogramming.
Or read this on Hacker News