new keyword 'extension' really necessary?

Osvaldo Doederlein opinali at gmail.com
Thu Aug 5 11:25:56 PDT 2010


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).

And I think the similar style (same syntax for annotation defaults and
for extension methods) is actually good. These are basically the same
thing, in a very abstract level: a structure (interface or annotation)
that has some feature (annotation field or method) which offers a
default "value".

2010/8/5 Brian Goetz <brian.goetz at oracle.com>:
> In addition to Maurizio's syntactic arguments, we believe there is value in
> identifying extension methods as, well, extension methods.

By the same logic, maybe we need an army of new redundant qualifiers
such as "method", "field", etc.?

(OTOH, we already have some redundant qualifiers - like 'abstract' for
a method signature that's not followed by '{', or allowing 'private
final' methods and 'public' interface methods, or 'final' for
arguments in abstract method declarations. But I don't want more of
the same.)

A+
Osvaldo

> On 8/5/2010 12:33 PM, Gernot Neppert wrote:
>> Hi Maurizio,
>>
>> I do not have compiler writing skils, so I'm curious why the keyword
>> 'extension' should be nessesary to introduce defender methods.
>> A defender method declaration without the prefix 'extension' looks quite
>> distinguishable to me. Example:
>>
>> interface List<E>
>> {
>>      void sort(Comparator<? super E>  comp) default Collections.sort(List<E>);
>> }
>>
>> So, why the new keyword?
>>
>> (An answer such as 'This is necessary to disambiguate the grammar' would
>> suffice...)
>>
>>
>>
>
>


More information about the lambda-dev mailing list