Proposal: Collection Literals
Joshua Bloch
jjb at google.com
Mon Mar 30 19:29:57 PDT 2009
Neal,
Sorry, I'm still confused. Can you tell me what client code would cause
trouble, or at least give me a few examples?
Thanks,
Josh
On Mon, Mar 30, 2009 at 5:58 PM, Neal Gafter <neal at gafter.com> wrote:
> 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