4 ms·
I was familiar with the problem but didn't have a name for it; thanks for providing me with one. What kind of work has there been on creating programming parad
by jake-low 10y ago
I was familiar with the problem but didn't have a name for it; thanks for providing me with one.
What kind of work has there been on creating programming paradigms that make it easy to both add new types and new methods? Is it a CAP-theorem-type problem where every solution is a trade-off, or is there a way to have your cake and eat it too?
- chenglou 10y agoThere are languages (libraries) that solve it. For reference, check Clojure's multimethods and OCaml's polymorphic variants.
- smallnamespace 10y agoThe tradeoff is that techniques like multimethods significantly weaken the contract that people normally expect from methods/classes. For example, if I'm writing a normal Java class, I know where I go to find methods dealing specifically with instances Foo (namely Foo and its children and direct users); with multimethods, it's more likely that there is some multimethod out there in an unrelated class that looks for instances of Foo.
- eru 10y agoGood tooling (think something along the lines of Hoogle) can help here.
- edwintorok 10y agoThe OCaml solution with polymorphic variants: http://www.math.nagoya-u.ac.jp/~garrigue/papers/fose2000.html http://www.math.nagoya-u.ac.jp/~garrigue/papers/fose2000.htm.... A very good summary of that paper is available here: http://lambda-the-ultimate.org/node/1518#comment-17566 http://lambda-the-ultimate.org/node/1518#comment-17566 Another alternative based on recursive modules: http://www.math.nagoya-u.ac.jp/~garrigue/papers/#privaterows http://www.math.nagoya-u.ac.jp/~garrigue/papers/#privaterows
- ufo 10y agoThere is plenty of research out there about trying to solve the expression problem and the wikipedia article has links to some of them: https://en.wikipedia.org/wiki/Expression_problem https://en.wikipedia.org/wiki/Expression_problem That said, there is a complexity and readability trade-off (that is hard to quantify) because these more flexible programming patterns that can solve the expression problem are more complicated than plain method dispatching or switch statements.
- glibgil 10y agoThe comments in this thread and the link to ltu in this thread talk about one of the simplest and most elegant solutions to the expression problem https://m.reddit.com/r/haskell/comments/4gjf7g/is_solving_the_expression_problem_worth_the_bother/ https://m.reddit.com/r/haskell/comments/4gjf7g/is_solving_th...
- optforfon 10y agohere was an interesting proposal for a solution in C++ https://channel9.msdn.com/Events/CPP/C-PP-Con-2014/0007-Accept-No-Visitors https://channel9.msdn.com/Events/CPP/C-PP-Con-2014/0007-Acce...