groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul King <pa...@asert.com.au>
Subject Re: [VOTE]Support package scope via `package` keyword
Date Sat, 30 Dec 2017 02:34:31 GMT
On Fri, Dec 29, 2017 at 9:35 PM, Jochen Theodorou <blackdrag@gmx.org> wrote:

> On 29.12.2017 11:58, Paul King wrote:
> [...]
>
>> I am unsure if I made myself clear. I think the default should remain as
>> CLASS but there could be an additional ALL enum value. Then again we could
>> just have a PackageScopeTarget[] ALL constant (though we have an
>> outstanding issue around using constants in annotation attributes we'd have
>> to check didn't get in the way).
>>
>
> It doesn´t make sense on local variables, the package, parameters or
> parameter types... Maybe I misunderstood what you mean with "ALL"
>

When you annotate a class like this:

```
import groovy.transform.PackageScope
import static groovy.transform.PackageScopeTarget.METHODS

@PackageScope(METHODS)
class Foo {
    def method1() {}
    def method2() {}
    def method3() {}
}
```

Then, the three methods are package private and the class is public.

You can alternatively have: @PackageScope([METHODS, CONSTRUCTORS]) or
whatever combinations
you like. For a class with many methods, fields, constructors this is much
more concise than an extra keyword on each member.
I was suggesting ALL as a constant [METHODS, CONSTRUCTORS, FIELDS, CLASS].
Like Cédric, I am not a huge fan of using just package as the keyword and
if we use `package private`, then deprecating the
shorthand variant could lead to ugly verbose code.

Cheers, Paul.


> bye Jochen
>

Mime
View raw message