Default methods syntax/semantics [Re: Updated State of the Lambda]
Stephen Colebourne
scolebourne at joda.org
Mon Dec 12 16:21:19 PST 2011
On 12 December 2011 23:43, Brian Goetz <brian.goetz at oracle.com> wrote:
>> Having said all that, perhaps examining the "default none" case in
>> isolation may miss something. For example, here is an interesting
>> alternative approach to the whole area - requiring defaulting
>> interfaces to declare themselves as such, similar to the way abstract
>> classes have to:
>> interface A {
>> void a(); // normal interface, no defaulting allowed
>> }
>> default interface B {
>> void a(); // normal interface method
>> void b() { ... } // interface method with default body
>> }
>> default interface C extends B {
>> void a(); // reabstraction
>> void b() { B.super.b() } // override for documentation, as per classes
>> void c(); // normal interface method (same syntax as reabstraction)
>> }
>
>
> Which means that adding "default" to an interface is not a binary compatible
> change, since it changes the meaning of declarations like a(). I don't
> think that flies.
I didn't say anything about how it compiles to bytecode. I can see no
reason why this approach cannot be syntax level only compiling down to
exactly how you plan to do it anyway (in the second of my two default
examples, not the first you commented on above).
Anyway, I'd like to hear other views as to the use of the "default" keyword.
Stephen
More information about the lambda-dev
mailing list