3 ms·
Adding new datatypes vs. adding new functions is the core tension between OOP and FP. It's really easy to add new functionality to existing datatypes in functio
by thurn 15y ago
Adding new datatypes vs. adding new functions is the core tension between OOP and FP. It's really easy to add new functionality to existing datatypes in functional programming, and really easy to add new datatypes in OOP.
There's some very interesting research on resolving this issue: http://www.cs.ucla.edu/~todd/research/icfp02.html http://www.cs.ucla.edu/~todd/research/icfp02.html
- KeithMajhor 15y agoOOP has problems adding existing functionality to new types. Interfaces are a go at the problem but they fall short for several reasons. Clojure's protocols are a better solution (as far as I can tell). Clojure also provides multi-methods and hierarchies for more sophisticated function dispatch. Their use and the reasoning behind their design is well documented on Clojure's website.