As I understand it, in languages like Haskell, and also as part of the lambda calculus, each lambda expression has its own scope, so if I have nested lambda expressions like: \x -> (\x -> x) , then the first parameter \x is different from the second \x .
In Java, if you do this, you will get a compilation error, as if you would use x again as the parameter name or the local variable name in lambda if it was already used inside the enclosing area, for example. as a parameter to the method.
Does anyone know why Java implemented lambda expressions in this way - why don't they introduce a new level of reach and behave like an anonymous class? I suppose this is due to some kind of limitation or optimization, or, perhaps, because lambdas needed to be hacked into an existing language?
source share