Updated State of the Lambda
Rémi Forax
forax at univ-mlv.fr
Mon Dec 12 09:14:39 PST 2011
On 12/12/2011 04:25 PM, Brian Goetz wrote:
>> Another solution would be to use the abstract keyword, perhaps at the
>> end in place of "default none".
> No, that already means something (actually, it is defined to mean
> nothing in that context.)
>
> I think you should make sure you understand the feature as designed
> better before declaring that getting rid of it would "make perfect sense."
>
> If you don't understand the feature as designed, you can ask. Or you
> can wait for the more detailed explanation that is surely forthcoming,
> but just hasn't arrived yet.
>
>
Don't be so harsh with Stephen,
I've followed exactly the same path, 'default' is ugly the first
time you see it and 'default none' is uglier, but after writing
some use cases it's obvious that this is the right choice.
You need default because you need to express the fact that
a method defined in a super-class will always win to one
defined in an interface.
class A {
void m() { ... }
}
interface I {
void m() default { ... }
}
class B extends A implements I {
// inherits from A::m(),
}
and you need 'default none' to re-abstract a method of an interface,
i.e. to say I don't want to inherits from the default implementation.
interface I {
void m() default { ... }
}
interface J extends I {
void m() default none;
}
class A implements J {
// don't compile, you need to provide a code for m()
}
Because methods defined in an interface are always abstract,
you can't use abstract instead of default none.
Using abstract at the end of the method signature
interface J extends I {
void m() abstract;
}
is in my opinion silly, I know that Java re-use the same keyword in
different
context for different semantics but because people confound syntax and
semantics
it will be a real mess.
cheers,
Rémi
More information about the lambda-dev
mailing list