Re:Java 8 lambda syntax decided - same as C# and Scala
by BDFL_Xenu on Thursday September 08, 2011 @08:55PM
(#2976323)
I see that the proposed lambda expressions can omit type annotations on the parameters. Does that mean that Java 8 will have at least some limited form of type inference?
[ Parent
| on HN ]
Re:Java 8 lambda syntax decided - same as C# and Scala
by spullara on Thursday September 08, 2011 @09:12PM
(#2976354)
The single abstract method interface type of a lambda will be inferred by its declaration site.
Re:Java 8 lambda syntax decided - same as C# and Scala
by umjames on Thursday September 08, 2011 @11:18PM
(#2976635)
Will they be full closures and remember the state of objects in scope?
Re:Java 8 lambda syntax decided - same as C# and Scala
by BDFL_Xenu on Friday September 09, 2011 @10:35AM
(#2978241)
If they will be based on anonymous inner classes, then yes, they'll capture the variables from the surrounding scope. Those variables however will be 'final', which means that you can't re-assign them, even if their values are still liable to side-effects (e.g. setting fields, mutating collections, etc).