Bryce L Nordgren wrote:
Jess Holle <[EMAIL PROTECTED]> wrote on 03/12/2007 03:09:49 PM:

Bryce L Nordgren wrote:
Thing 2: (snipped)
========
Generics do not even
contain a way to express "this collection is potentially composed of a
mixture of elements, but every element is guaranteed to be between
{Parent}
and {Child} in the class hierarchy".  In order to implement this type
of
checked behavior, Java Generics requires that we use the "unchecked"
syntax.

You can express the bounds of <? extends A super B>, right?  There's
even a more obscure syntax for expressing something that extends
multiple classes in cases.

My fears have just been amplified by about an order of magnitude.  Your
expression does not repeat _NOT_ mean: "this collection is potentially
composed of a mixture of elements, but every element is guaranteed to be
between {Parent} and {Child} in the class hierarchy".  It means "this
collection contains elements all of the same type, and this type is
guaranteed to be between {Parent} and {Child}."
Yes, that's true.
Use Java generics to express concepts that Java generics actually contains
a vocabulary for.  However, please do not exclude current functionality
merely because Java generics cannot articulate the concept.
I never said generics could articulate everything. [Though I believe you could articulate what you want with generics -- it just requires that you have Collection<A,B extends A>, express appropriate constraints on all methods, etc.] To do so would have resulted in something utterly unusable.

I wasn't proposing removing existing orthogonal/non-redundant type-enforcement capability.
Generics is a minefield.  Please be extremely cautious.
Generics in general are *not* a minefield but rather are a great safety net.

Properly implementing a library of genericized type library for all cases can admittedly be /very/ tricky. This effort then pays dividends to all the folk who use this library.

--
Jess Holle

Reply via email to