5 ms·
Functional programmers will reply that you can use partial evaluation and higher-order functions to do that. The sad reality is that since so many people are o
by colllectorof 7y ago
Functional programmers will reply that you can use partial evaluation and higher-order functions to do that.
The sad reality is that since so many people are only familiar with the strawman version of OOP rather than the real thing intelligently discussing the advantages and disadvantages of these paradigms is very hard.
- hota_mazi 7y agoYes, I've heard them say that indeed. They often gloss over a lot of issues about these. For example, partial evaluation is limited by the fact that parameters need to be ordered a certain way and you can't realistically cover all combinations. Higher order functions don't enable any kind of useful specialization at all. And of course, all modern OOP languages also support higher order functions, so they are the ones giving you more tools.
- tome 7y agoCould you give some concrete examples? At the moment it's just assertions.
- nitrogen 7y agoDo any functional languages support partial evaluation using named parameters? That would solve the parameter ordering complaint. As for higher order functions you would write a function that does the 90% and accepts a function parameter for the other 10%.
- kragen 7y agoOCaml has named (“labeled”) parameters, and of course you can use combinators like flip to bind positional parameters like the second or third. I'm not sure what the relevance to inheritance is, though, and “partial evaluation” usually means an optimization strategy rather than just currying.
- catalogia 7y agoRacket's curry supports keyword arguments. https://docs.racket-lang.org/reference/procedures.html#%28def._%28%28lib._racket%2Ffunction..rkt%29._curry%29%29 https://docs.racket-lang.org/reference/procedures.html#%28de... (god links into the racket docs are ugly...)
- hota_mazi 7y ago> As for higher order functions you would write a function that does the 90% and accepts a function parameter for the other 10%. Surely you see how this doesn't scale, right? You would need to first write your code, then abstract every single piece of it as a call to a function passed in parameters. Now your function is accepting five different functions in parameters, and calls them. This is a terrible and impossible to scale way to emulate class specialization.
- ErotemeObelus 7y ago> Surely you see how this doesn't scale, right?... This is a terrible and impossible to scale way to emulate class specialization. <Kelsey Grammar Voice> Heretic! Have not the elders of our holy church indeed canonized the ex cathedra dogmas of variable immutability and higher-order functions with closed variables? And indeed have we not been in ecumenical agreement over the incomprehensible mystery of the trinity of higher order types, dependent types, and polymorphic types? Dare ye teach heresy proudly with thy contumely? Anathema sit!
- tome 7y agoSo put those parameters in a single record type and just override the 10% of them that you need to.
- kragen 7y agoAbadi and Cardelli identified some ways that this solution falls short—in particular, the self parameter isn't covariant—and how to fix them.