3 ms·
You can write functional code in any language, just as you've shown. But your mistake perfectly elucidates the point. When you call a function in a functional
by solipsism 11y ago
You can write functional code in any language, just as you've shown. But your mistake perfectly elucidates the point. When you call a function in a functional language, you know the variable you pass as the parameter won't be mutated. When you call a function in a non-functional language, you only hope it won't.
And even when the type system allows you to know the input variable won't be mutated (say, passing by copy in C++), you don't know what other kinds of side-effects the function may be having.
- sampo 11y agoFortran, usually not regarded a functional language, has `pure` keyword to declare that a function (or procedure) has no side effects, and `intent(in)` to declare that a function argument will not be mutated.