1

Topic: For what the requirement effectively final is necessary?

Why it is impossible to change a variable from a function lambda? Why variables functions used in a lambda should be effectively final?

2

Re: For what the requirement effectively final is necessary?

Hello, aClass, you wrote: a C> Why it is impossible to change a variable from a function lambda? Why variables functions used in a lambda should be effectively final? Because the variable is stored on a stack, and the lambda can be caused, when original function finished for a long time performance and a variable for a long time has been destroyed. It could be bypassed, using lambdas, which cannot be saved to cause later (less powerful model, than used now) or automatically carrying out such variables from a stack in a heap, but designers Java decided so not to do. Upon value of all variables used by a lambda are simply copied in object of a lambda and all. If they are not-final, their any changes after copying will not be visible in a lambda that can tangle the programmer.

3

Re: For what the requirement effectively final is necessary?

Hello, vsb, you wrote: vsb> Upon value of all variables used by a lambda are simply copied in object of a lambda and all. But why them not to change directly in this object? vsb> if they will be not-final, their any changes after copying will not be visible in a lambda that can tangle the programmer. If such nonsense can tangle the programmer, it always has a possibility to go to trade in pies.

4

Re: For what the requirement effectively final is necessary?

Hello, cures, you wrote: vsb>> Upon value of all variables used by a lambda are simply copied in object of a lambda and all. A C> But why them not to change directly in this object And if objects one thousand? The list from lambdas, for example.

5

Re: For what the requirement effectively final is necessary?

6

Re: For what the requirement effectively final is necessary?

Hello, cures, you wrote: vsb>> Upon value of all variables used by a lambda are simply copied in object of a lambda and all. A C> But why them not to change directly in this object? Following step you will ask volatile for local variables? vsb>> if they will be not-final, their any changes after copying will not be visible in a lambda that can tangle the programmer.> If the programmer such nonsense can tangle a C, it always has a possibility to go to trade in pies. , .

7

Re: For what the requirement effectively final is necessary?

Hello, aClass, you wrote: a C> Why it is impossible to change a variable from a function lambda? Why variables functions used in a lambda should be effectively final? It is possible, but not in Java) Scala, for example, turns not-final local variables in a class-wrapper, and the link already on it is copied in a lambda copy. Basically, in Java it is possible to emulate such behavior manually through ` org.apache.commons.lang.mutable`