Proposal: Collection Literals

Neal Gafter neal at gafter.com
Mon Mar 30 17:58:10 PDT 2009


On Mon, Mar 30, 2009 at 5:45 PM, Joshua Bloch <jjb at google.com> wrote:
> Could you please be a be a bit more specific?  In particular, could you
> provide an example of  something that this proposal precludes but the
> for-each construct (which is already in the language) does not?  Once we
> have such an example, we'll be able to weigh the pros and cons
> intelligently.

Sure.  As the proposed construct is defined to create non-reified
collection types, and that distinction may be highly visible to
programmers, programs using the proposed syntax would have to continue
creating non-reified collections.

With the for-each loop, on the other hand, the only object created by
the construct is an iterator.  The iterator is constructed by a
library method that is completely under control of the Iterable that
comes in, and hidden from code containing the for-each loop.  While
non-reified types might continue to produce non-reified iterators,
reified classes may well produce reified iterators.



More information about the coin-dev mailing list