Pure functions and Java
|Added at||2016-12-27 11:12|
I have several doubts about Java and pure functions. As far as I know, a pure function is a function for which these two statements hold:
According to that (and as an example), this function would be pure:
However, would this function be considered pure?
My guess is no, because the result is different depending on the Person objects that you pass as parameters to the function.
Taking into account that objects in Java (and OO languages in general) have hidden information, could any function that involves objects as parameters be considered pure?
Another question, can a language/program be considered pure if any of its functions is not pure?
Taking into consideration all this, could a Java program (fairly complex) be composed only of pure functions (be pure, so to say) or is it just something impossible?
Another question, as far as the compiler is concerned, a lambda expression can only use final (or effectively final) variables:
How is it possible that that being the case this code compiles?