Package specific syntax

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Package specific syntax

Nathan Harvey
In Java,  methods and fields use package scope by default. In Groovy, they
use public. In order to make something package scope, you have to use the
@PackageScope annotation. This makes code look a bit messy but also doesn't
seem very intuitive. What if the "package" keyword was able to be applied,
in exactly the same way as "public" and "private" are?

Example:
package void foo() {}



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
Reply | Threaded
Open this post in threaded view
|

Re: Package specific syntax

daniil.ovchinnikov
This is the best way from IDE perspective.



Daniil Ovchinnikov
JetBrains
jetbrains.com
“Drive to develop"

On 14 Dec 2017, at 01:03, Nathan Harvey <[hidden email]> wrote:

In Java,  methods and fields use package scope by default. In Groovy, they
use public. In order to make something package scope, you have to use the
@PackageScope annotation. This makes code look a bit messy but also doesn't
seem very intuitive. What if the "package" keyword was able to be applied,
in exactly the same way as "public" and "private" are?

Example:
package void foo() {}



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html

MG
Reply | Threaded
Open this post in threaded view
|

Re: Package specific syntax

MG
"this" in this case being bound to ?-)
(i.e. what do you mean by "this" - having a package keyword or an annotation ?)

-------- Ursprüngliche Nachricht --------
Von: Daniil Ovchinnikov <[hidden email]>
Datum: 13.12.17 23:14 (GMT+01:00)
Betreff: Re: Package specific syntax

This is the best way from IDE perspective.



Daniil Ovchinnikov
JetBrains
jetbrains.com
“Drive to develop"

On 14 Dec 2017, at 01:03, Nathan Harvey <[hidden email]> wrote:

In Java,  methods and fields use package scope by default. In Groovy, they
use public. In order to make something package scope, you have to use the
@PackageScope annotation. This makes code look a bit messy but also doesn't
seem very intuitive. What if the "package" keyword was able to be applied,
in exactly the same way as "public" and "private" are?

Example:
package void foo() {}



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html

Reply | Threaded
Open this post in threaded view
|

Re: Package specific syntax

Nathan Harvey
This post was updated on .
CONTENTS DELETED
The author has deleted this message.
Reply | Threaded
Open this post in threaded view
|

Re: Package specific syntax

daniil.ovchinnikov
This: 

Example:
package void foo() {}



Daniil Ovchinnikov
JetBrains
jetbrains.com
“Drive to develop"

On 14 Dec 2017, at 01:37, Nathan Harvey <[hidden email]> wrote:

I meant that the @PackageScope annotation made code look somewhat unreadable,
and that the "package" keyword would be an ideal solution.



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html

MG
Reply | Threaded
Open this post in threaded view
|

Re: Package specific syntax

MG
In reply to this post by daniil.ovchinnikov
Why is a keyword better than an annotation from an IDE developer's perspective (considering Groovy already has tons of annotations which more complex semantics than @PackageScope) ?


On 13.12.2017 23:14, Daniil Ovchinnikov wrote:
This is the best way from IDE perspective.



Daniil Ovchinnikov
JetBrains
jetbrains.com
“Drive to develop"

On 14 Dec 2017, at 01:03, Nathan Harvey <[hidden email]> wrote:

In Java,  methods and fields use package scope by default. In Groovy, they
use public. In order to make something package scope, you have to use the
@PackageScope annotation. This makes code look a bit messy but also doesn't
seem very intuitive. What if the "package" keyword was able to be applied,
in exactly the same way as "public" and "private" are?

Example:
package void foo() {}



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html


MG
Reply | Threaded
Open this post in threaded view
|

Re: Package specific syntax

MG
In reply to this post by Nathan Harvey
Hi Daniil,

thank you for explaining that, as most devs with regards to IDEs I am a user and have little insight in the challenges of its inner workings.

I have never had the need to use @PackageScope, but the problem I see is that the annotation (in typical Groovy style), can do more than a keyword, due to it supporting parameters to restrict its applicability to e.g. class fields only - so I guess you would have to scan for @PackageScope in any case...

Cheers,
mg


-------- Ursprüngliche Nachricht --------
Von: Daniil Ovchinnikov <[hidden email]>
Datum: 15.12.17 14:13 (GMT+01:00)
An: MG <[hidden email]>
Betreff: Re: Package specific syntax

Each annotation requires resolution, which slows the IDE. With a keyword we can get visibility of members instantly, for example for showing appropriate icon in Project View.

We need to resolve _all_ annotations and check if there are annotation collectors just to find that given member doesn’t have @PackageScope. 
At this point all we need to know is whether containing class of a given member has @PackageScope, and we start to resolve all annotations of a class and so on.



Daniil Ovchinnikov
JetBrains
jetbrains.com
“Drive to develop”

On 14 Dec 2017, at 04:11, MG <[hidden email]> wrote:

Why is a keyword better than an annotation from an IDE developer's perspective (considering Groovy already has tons of annotations which more complex semantics than @PackageScope) ?


On 13.12.2017 23:14, Daniil Ovchinnikov wrote:
This is the best way from IDE perspective.



Daniil Ovchinnikov
JetBrains
jetbrains.com
“Drive to develop"

On 14 Dec 2017, at 01:03, Nathan Harvey <[hidden email]> wrote:

In Java,  methods and fields use package scope by default. In Groovy, they
use public. In order to make something package scope, you have to use the
@PackageScope annotation. This makes code look a bit messy but also doesn't
seem very intuitive. What if the "package" keyword was able to be applied,
in exactly the same way as "public" and "private" are?

Example:
package void foo() {}



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html



Reply | Threaded
Open this post in threaded view
|

Re: Package specific syntax

daniil.ovchinnikov
In reply to this post by Nathan Harvey
I’d love `@PackageScope` to be removed (or deprecated) in favor of `package` keyword. In this case I woudn’t have to scan for it.



Daniil Ovchinnikov
JetBrains
jetbrains.com
“Drive to develop”

On 15 Dec 2017, at 16:36, mg <[hidden email]> wrote:

Hi Daniil,

thank you for explaining that, as most devs with regards to IDEs I am a user and have little insight in the challenges of its inner workings.

I have never had the need to use @PackageScope, but the problem I see is that the annotation (in typical Groovy style), can do more than a keyword, due to it supporting parameters to restrict its applicability to e.g. class fields only - so I guess you would have to scan for @PackageScope in any case...

Cheers,
mg


-------- Ursprüngliche Nachricht --------
Von: Daniil Ovchinnikov <[hidden email]>
Datum: 15.12.17 14:13 (GMT+01:00)
An: MG <[hidden email]>
Betreff: Re: Package specific syntax

Each annotation requires resolution, which slows the IDE. With a keyword we can get visibility of members instantly, for example for showing appropriate icon in Project View.

We need to resolve _all_ annotations and check if there are annotation collectors just to find that given member doesn’t have @PackageScope. 
At this point all we need to know is whether containing class of a given member has @PackageScope, and we start to resolve all annotations of a class and so on.



Daniil Ovchinnikov
JetBrains
jetbrains.com
“Drive to develop”

On 14 Dec 2017, at 04:11, MG <[hidden email]> wrote:

Why is a keyword better than an annotation from an IDE developer's perspective (considering Groovy already has tons of annotations which more complex semantics than @PackageScope) ?


On 13.12.2017 23:14, Daniil Ovchinnikov wrote:
This is the best way from IDE perspective.



Daniil Ovchinnikov
JetBrains
jetbrains.com
“Drive to develop"

On 14 Dec 2017, at 01:03, Nathan Harvey <[hidden email]> wrote:

In Java,  methods and fields use package scope by default. In Groovy, they
use public. In order to make something package scope, you have to use the
@PackageScope annotation. This makes code look a bit messy but also doesn't
seem very intuitive. What if the "package" keyword was able to be applied,
in exactly the same way as "public" and "private" are?

Example:
package void foo() {}



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html