From virtual extension methods to mixins

Rémi Forax forax at univ-mlv.fr
Tue Jul 10 02:18:49 PDT 2012


On 07/10/2012 10:47 AM, James Shaw wrote:
> On 10 July 2012 09:42, Rémi Forax <forax at univ-mlv.fr 
> <mailto:forax at univ-mlv.fr>> wrote:
>
>     On 07/10/2012 09:06 AM, James Shaw wrote:
>     > On 10 July 2012 02:02, Brian Goetz <brian.goetz at oracle.com
>     <mailto:brian.goetz at oracle.com>> wrote:
>     >
>     >> Yes, this is what I call the "virtual field pattern."  It seems
>     perfectly
>     >> reasonable to me, because the classes that mix you in have to
>     consent by
>     >> providing the {get,set}Peeker methods.  (Also, by the nature of
>     interface
>     >> method merging, it addresses the diamond problem as if all base
>     classes
>     >> were "virtual".)
>     >>
>     >>
>     >>
>     > Can you explain what you mean by 'diamond problem'?
>     >
>
>     It's a classical problem of multiple inheritance,
>     let suppose we have:
>
>     class A {
>        int a;
>     }
>     class B extends A {}
>     class C extends A {}
>     class D extends B, C {}
>
>     The question is how many 'a' you have in D, using an abstract
>     getter in A
>     solves the problem because in that case you have only one field in D.
>
> Aha!  I was trying to figure out how multiple inheritance was related 
> to Java 7 diamond syntax.  Whoops ;-)

In Java unlike in C++, diamonds are developers best friends*

Rémi
* me singing in front of my laptop.




More information about the lambda-dev mailing list