Lambdas in for-each loops

Maurizio Cimadamore maurizio.cimadamore at
Wed Sep 5 04:29:37 PDT 2012

On 05/09/12 11:52, Peter Levart wrote:
> I don't know about compiler internals but "proceed" attempt in the above is
> meant to represent some kind of attribution phase on the clone of the sub-tree
> that represents the "exp" so that the unsuccessfull attribution effects can be
> undone and re-tried with different input...
I think the point is: is there enough value in the proposed feature (add 
lambda support in for-each loop) to justify this increase in complexity? 
If the main use case is to convert an existing iterator into an Iterable 
instance, it seems to me that we can achieve a very similar effect w/o 
any language modification and using an API-base approach:

for (String s : Iterables.asIterable(it)) { ... }

Which, with some static import magic can be reduced to:

for (String s : asIterable(it)) { ... }

Which is even shorter than the lambda version.


More information about the lambda-dev mailing list