Brian Goetz brian.goetz at oracle.com
Mon Dec 19 06:51:11 PST 2011


Just because you can, doesn't mean you should....

On 12/19/2011 4:11 AM, Zhong Yu wrote:
> Is it not possible to add state to interface through default methods?
>
>      interface WithFoo
>          int getFoo() default {  return fooMap.get(this);  }
>          void setFoo(int x) default { fooMap.set(this, x); }
>
>      static WeakConcurrentMap fooMap = new ...;
>
> Zhong Yu
>
> On Mon, Dec 19, 2011 at 2:35 AM, Lukas Eder<lukas.eder at gmail.com>  wrote:
>>> I understand extension methods are vital for evolving interfaces.
>>> But in my opinion they should be used for just that. If we start
>>> adding "final" extension methods too, then why not simply
>>> introduce multiple inheritance straightaway?
>>
>> According to page 42 of the presentation I mentioned, extension
>> methods really *are* an additional means of multiple inheritance,
>> "final" or not. Interfaces already provide multiple inheritance of
>> types, now there'll also be multiple inheritance of "behaviour", or
>> something similar to "stateless traits":
>> http://blogs.oracle.com/briangoetz/resource/devoxx-lang-lib-vm-co-evol.pdf
>>
>> Whether "final" is allowed or not is probably not very important to
>> that discussion.
>>
>> Regards,
>> Lukas
>>
>


More information about the lambda-dev mailing list