Problem of defender methods with generic methods

Alex Buckley alex.buckley at oracle.com
Mon Nov 15 16:49:05 PST 2010


On 11/15/2010 4:32 PM, Steven Simpson wrote:
> No, I'm simply talking about the static alternative to extension
> methods, as C# has (AIUI), which are just syntactic sugar for a static
> method call.  The problem shouldn't arise there, as the existence of an
> extension method like max() doesn't require that all Lists have its
> additional <? extends Comparable> constraint.  (1) and (2) are
> semantically equivalent.

Ah, the benefits of _use-site_ extension methods. (Whether static or 
dynamic.)

> (I've slightly transposed Ali's problem by imagining that he'd prefer to
> add these extensions directly to List, and that he's only introduced
> CustomizedList for the sake of toying with the new language features.  I
> don't think that fundamentally alters the problem though, which is that
> two of his extensions work best with List<T>, while the other one
> demands List<T extends Comparable>.)

Exactly.

Alex



More information about the lambda-dev mailing list