From virtual extension methods to mixins

James Shaw js102 at zepler.net
Tue Jul 10 01:47:43 PDT 2012


On 10 July 2012 09:42, Rémi Forax <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> 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 ;-)


More information about the lambda-dev mailing list