C++: Pure vs Impure Functions

Channel:
Subscribers:
2,650
Published on ● Video Link: https://www.youtube.com/watch?v=JDs3mMsdnh0



Duration: 24:10
521 views
12


While C++ is not a purely functional language, it can really help make your code easier to understand if you use the notion of function purity (from functional programming) to guide the design of your functions. By cutting down the dependencies of a function to just the input parameters of the function, then you can help eliminate the exponential complexity of sources of bugs that plague more complex systems, as well as enabling the compiler to do things like flag pure functions whose return values are dropped and turning on some optimizations.