Timeline for Is ad-hoc polymorphism a good practice in functional programming?
Current License: CC BY-SA 4.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 12, 2021 at 21:06 | comment | added | Doc Brown | @Caleth: ok, I have to admit, I think the solution which confused me was the one you stripped out of the answer in your last edit. Your monkey patching approach is surely readable and simple, however, it isn't semantically equivalent to the original code. | |
Nov 12, 2021 at 18:32 | comment | added | Jörg W Mittag | The paper that introduces type classes is literally titled "How to make ad-hoc polymorphism less ad hoc". | |
Nov 12, 2021 at 17:13 | comment | added | Karl Bielefeldt | @DocBrown, extension methods are the simulation. Monkey patching is the older and more powerful technique. I very much prefer static typing, and even I have a hard time arguing those three lines in his first example aren't a prime example of the benefit of a dynamic language. It can't get much simpler. | |
Nov 12, 2021 at 16:20 | comment | added | Caleth |
@DocBrown def creates an object, and binds it to a name in a scope. The code in my answer takes an existing object and binds it to a name in a scope.
|
|
Nov 12, 2021 at 15:20 | comment | added | Doc Brown | To be honest, Caleth's solution does look more like an ugly hack to me, to simulate extension methods in Python. The OP's code is something I understand immediately. | |
Nov 12, 2021 at 14:09 | history | answered | Karl Bielefeldt | CC BY-SA 4.0 |