3 ms·
I was planning on mentioning it as soon as I saw this post as well. I think most people who try using a functional programming language that encourages you to u
by anaphor 9y ago
I was planning on mentioning it as soon as I saw this post as well. I think most people who try using a functional programming language that encourages you to use sum types (at least when you're beginning) run into this in some way, but most people probably aren't aware that it has an actual name.
Here's a post on solving it using type classes in Haskell, if people are curious! http://koerbitz.me/posts/Solving-the-Expression-Problem-in-Haskell-and-Java.html http://koerbitz.me/posts/Solving-the-Expression-Problem-in-H...
- jfoutz 9y agoI was going to link the same article! I think the interesting part is the similarity between haskell and clojure. Essetially programming to very small classes/protocols. The linked article is cool, because i think the java approach would generalize to the OP's C++ solution, and be able to eliminate that gross dynamic cast.