News for hackers. Stuff that matters.
Re:Differentiable Programming Manifesto by dnautics on Thursday November 14, 2019 @02:16AM (#21533461)
You can overload any function in c++. It's multiple dispatch.
Re:Differentiable Programming Manifesto by ddragon on Thursday November 14, 2019 @08:07AM (#21535053)
Multiple dispatch is a little more than just overload. In C++ if you have a base class Animal with two derived Dog and Cat, and you have an Animal * pointer to Dog or Cat and do animal->walk() it will dispatch to either the Dog or Cat method (single dispatch). If you do animal->meet(animal) it will dispatch to either dog.meet(Animal * ) or cat.meet(Animal * ), not dog.meet(Dog * ) or cat.meet(Cat * ) like multiple dispatch languages do. You need a visitor pattern in C++ (or apparently templates) to get double dispatch:

https://en.wikipedia.org/wiki/Visitor_pattern#C++_example