A polyglot's guide to multiple-dispatch (2016)

71 pointsposted 5 months ago
by andsoitis

16 Comments

Panzerschrek

5 months ago

As I know C++ now allows multiple dispatch for std::variant: https://en.cppreference.com/w/cpp/utility/variant/visit2.htm....

And std::variant is now a better choice for cases like in the article above, where previously inheritance was used to represent a closed set of possible subtypes.

RossBencina

5 months ago

Where "now" means C++17 or C++20 depending on whether or not you understand what INVOKE<R> semantics are?

maattdd

5 months ago

TIL that std::visit supports multiple variants. How new is that ?

MathMonkeyMan

5 months ago

Always did, as far as I know. Never knew why...

ur-whale

5 months ago

Would have been nice to mention that it's one thing that Julia seem to have gotten right.

Jtsummers

5 months ago

It's a series of articles, Julia is (briefly) mentioned in Part 3.

fungiblecog

5 months ago

if only programmers cared about functionality as much as syntax we'd be living in a lisp heaven

3cats-in-a-coat

5 months ago

You need some sort of critical majority that cares about deeper aspects of whatever (over superfice) or else everyone focuses on superfice, as that's what all the public debates are about.

But lacking that, lisp could improve its syntax (did that, BTW not hard, just added some containers and a few standard infix operators, which all compile to lists).

lisper

5 months ago

Cue the smug Common Lisp weenies...

Oh, wait, that's me :-)

sevensor

5 months ago

Huh, that is cleaner than a giant pattern match. It would be nice to have this at work, I know exactly how I’d use it...

Oh no, this is how lisp ruins people, isn’t it.

adgjlsfhk1

5 months ago

don't worry. the Julia peeps can also be smug about this (as one)

upghost

5 months ago

To your point, I assume the "polyglot" part was referring to the arguments this would spawn in the comment section

shawn_w

5 months ago

Diligent Dylan hackers sound off!

...

...

...

Bueller?