Virtual extension methods -- a strawman design

Howard Lovatt howard.lovatt at gmail.com
Mon May 17 01:05:50 PDT 2010


Gernot,

You are correct in saying that nothing can be added that can't already
be done, i.e. you only gain convenience. To me though, writing:

list.sort();

would be a welcome addition compared to:

Collections.sort( list );

Like all features it is open to abuse, you can see that some API
designers will add many convenience methods and the API will bloat.
However, used well I think it will be a valuable addition and could
hopefully replace abstract classes in many instances.

Not so sure about your filter returning a new list of the same type
example. You may well want to return a different data structure,
perhaps one that shares the underlying elements so that you don't need
to generate a new array (or some other underlying structure) or you
generate the new array lazily. You can do what you want, same
underlying structure, in Scala, but the mechanism is complicated and I
am not sure worth the overhead of either the complicated typing that
is necessary or the coding idiom that you use.


  -- Howard.


More information about the lambda-dev mailing list