Re:Functional programming in C++ (2012)
by eyelidlessness on Monday December 28, 2020 @10:23PM
(#25566399)
There are some wildly imaginative benefits of FP sold in words by some advocates, oftentimes imagining what could be in a runtime or compiler based on the maths of what’s promised by the practice. It’s easy to imagine that if an expensive function call always produces the same results it can be optimized to a single call, after which all further calls are free (a memory access). It’s easy to then overstate or imply that calling a pure function guarantees that kind of optimization even if it doesn’t.
[ Parent
| on HN ]
Re:Functional programming in C++ (2012)
by zelphirkalt on Tuesday December 29, 2020 @01:05AM
(#25567202)
You are right of course, that this is not always implemented. I'd add though, that an impure implementation would never allow for such an optimization. The rest is the job of compiler developers. Of course you need to keep an eye on runtime execution cost as well. That is part of your job.