Extension Methods

Paul Benedict pbenedict at apache.org
Thu Dec 10 21:45:29 PST 2009


Mark,

First, thank you and very nice job writing up the proposal. It is a
great document to read! I suppose you could version control it in
Mercurial; then people can perform hi-tech diffs too.

With regard to extension methods, I think the "declaration-site"
extensions are mostly worthless. Interfaces shouldn't be used this way
since they are suppose to define a contract to implement. I dare to
say this is an abuse of the interface mechanism. The straw man says
such methods are "hidden in a class implementing that interface", but
I think it's a hack; it unnaturally bolts the feature to an
abstraction. Java has gone 6 full releases and 15 years with the
simple understanding what interfaces do. If extension methods are
really going to make an appearance in Java 7, I hope it can be done
without this unwieldy extension (pun) to interfaces. If this is all
that declaration-site extensions have to offer, it's simply not worth
it. I rather just use the static methods directly.

I'll quote Joshua Bloch from Peter Ahé's blog [1]: They "must be
regarded as a fundamental change to the nature of interfaces in Java.
I believe that interfaces are the heart and soul of the language,
hence am reluctant to mess with them."

I opt for this feature to be dropped.

[1] http://digital-sushi.org/entry/declaration-site-extension-methods/

Paul


More information about the lambda-dev mailing list