ACCEPTABLE?: List Comprehensions?
Joseph D. Darcy
Joe.Darcy at Sun.COM
Tue Mar 17 23:15:37 PDT 2009
Reinier Zwitserloot wrote:
> Ah, list comprehensions. I forgot them on my list. They aren't
> closures, but you can do quite a few closure use-cases with them, and
> are a lot easier to understand. The draft proposal looks good (but is
> incomplete; it doesn't mention any JLS chapters, for example), but
> there's one big issue it doesn't mention: If the list comprehensions
> return Iterables, then the generating expression, as well as the
> filter expressions, are effectively 'closures' and get all the
> complications that stem from this. For example, you would not be able
> to use non-final variables in there, unless we change the rules
> regarding usage of non-finals in 'closures', which involves a
> significant change for the JVM (it has to declare that variable on the
> heap and not on the stack).
>
> Generating the entire list on the spot has none of those issues, and
> turns the entire proposal into syntactic sugar + a new utility class
> in the spirit of Collections and Arrays, named 'Iterables'. That's all.
>
> Joe: If a list comprehension proposal is written that involves
> (extensive) syntax sugar + 1 new class file and nothing else, would
> they have a chance?
>
I would be doubtful such a change would be within scope.
-Joe
More information about the coin-dev
mailing list