groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesper Steen Møller <>
Subject Re: Inner traits?
Date Mon, 29 Feb 2016 10:52:16 GMT
Hi Jochen and Henry

> On 29. feb. 2016, at 11.29, Jochen Theodorou <> wrote:
> On 27.02.2016 19:29, Christophe Henry wrote:
> [...]
>> public class CustomApplication extends Application
>> {
>>     private static instance
>>         public ContextgetApplicationContext(){return instance.applicationContext
> Hmmm, I wonder if this can be made sense of or not. A trait can be seen as some independent
piece that can be added to a class. But for it to be independent, it cannot be non-static.
In your code the trait implementation would depend on an instance of CustomApplication and
cannot be created without supplying such an instance.

Henry’s example refers to a static field, so it wouldn’t require the outer instance, analogous
to an interface (which is static by definition).
Those semantics should be easy enough to cope with, if only the grammar (and taste!) would
allow it.

View raw message