by eweise · 12y ago · 0 comments
int a = 0; list.forEach(element -> { a++; // no way ! });
That's why it's a lambda and not a closure BTW.
IMO the lack of exception transparency is going to be more of an issue with Java's lambdas.
The lack of checked exception transparency is for me something that goes in the right direction. The hidden message is 'Use checked exception only for IOs and please don't create your own exceptions, use already existing ones !'
Closures come in two primary flavors, bind by value or bind by reference. Some languages implement only one of these, some implement both, some bind in completely different ways (e.g. lazy binding in Haskell).
final int[] a = {0};
list.forEach(element -> { a[0]++; });