new keyword 'extension' really necessary?
brian.goetz at oracle.com
Fri Aug 6 10:09:28 PDT 2010
Guiding Principle 1 for the Java Language: Reading code is more important that
Occasional DRY violations are perfectly allowed, and even encouraged, if they
further this principle. DRY is not an end unto itself.
Your opinion is noted, but I don't think there's any value in continuing this
thread. We have far more important things to focus on, and "I don't like this
syntax" discussions are tremendously distracting from the real goal, however
well-intentioned they are.
There is, however, tremendous value in you actually *trying* the prototype.
Have you done that? I welcome everyone's experience with what has been built
On 8/6/2010 12:10 PM, Gernot Neppert wrote:
> Osvaldo Doederlein schrieb:
>> 2010/8/5 Rémi Forax<forax at univ-mlv.fr>:
>>> Le 05/08/2010 20:25, Osvaldo Doederlein a écrit :
>>>> Extension methods are not allowed inside annotations, so I guess the
>>>> implementation and spec issues are at least less severe, as
>>>> disambiguation is trivial by the outer context being an annotation or
>>>> not. Maybe it can't be completely handled by (simple) grammar changes,
>>>> but that would be about it (it seems; correct me if that's wrong).
>>> In fact, there is no 'grammar' problem.
>>> The local keyword 'extension' avoid to change too much the javac parser,
>>> a hand written top-down recursive parser.
>>> But the real value is, as Brian says, that an extension method
>>> is tagged with the local keyword 'extension'.
>>> Easy to explain, easy to grasp.
>> You imply that without 'extension', the syntax is hard to explain,
>> hard to grasp. This is where I disagree. This verbose, DRY-violation
>> syntax won't buy anything; 'default' is perfectly fine, I don't think
>> programmers will be confused. Notice also that you assume that
>> programmers want to make the association between the syntax and the
>> feature name "extension method", but this name is just a convention
>> and in some degree arbitrary - we could decide to use "defender
>> method", or maybe even "default method" [in that case the 'default' is
>> certainly sufficient ;-) ]
> I think you have a good point here:
> the experts who came up with the idea of 'extension' have a certain
> perception of this new feature:
> For them, it shall only ever be used by so-called 'library developers'
> who will responsibly evolve existing interfaces.
> It seems they want to make sure that this view of theirs is somehow
> conveyed by the syntax.
> IMHO, that is a futile endeavour. People will use the new feature for
> whatever purpose comes to their minds. There will be no restriction to
> evolving Standard JDK interfaces.
> Technically, the new keyword 'extension' does not much sense. You can
> design an interface from scratch and make all methods 'extension
> methods' right from the beginning, e.g. for the sake of easier
> implementation by clients. Then, nothing is being 'extended'...
More information about the lambda-dev