You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by Daniel Sun <re...@hotmail.com> on 2017/01/19 07:13:37 UTC

The order of modifiers and annotations

Hi all,

       Currently the old parser allows mixing modifiers and annotations,
e.g.

*Current*
@interface Test1 {}
@interface Test2 {}
@Test1 final @Test2 a

*Suggested*
@interface Test1 {}
@interface Test2 {}
@Test1 @Test2 final a

         In addition, the order of modifiers is arbitrary too, e.g.

*Current*
class A {
    static final public a
}

*Suggested*
class A {
    public static final a
}

         I wonder it is feature of Groovy or some space we should
improve(e.g. check more strictly)?

Cheers,
Daniel.Sun



--
View this message in context: http://groovy.329449.n5.nabble.com/The-order-of-modifiers-and-annotations-tp5737808.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: The order of modifiers and annotations

Posted by Daniel Sun <re...@hotmail.com>.
I'll take a look at the issue later.

Cheers,
Daniel.Sun



--
View this message in context: http://groovy.329449.n5.nabble.com/The-order-of-modifiers-and-annotations-tp5737808p5737818.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: The order of modifiers and annotations

Posted by Daniel Sun <re...@hotmail.com>.
You're welcome :)



--
View this message in context: http://groovy.329449.n5.nabble.com/The-order-of-modifiers-and-annotations-tp5737808p5737826.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: The order of modifiers and annotations

Posted by Andres Almiray <aa...@gmail.com>.
Beautiful! thanks again Daniel. One more reason to get 3.0-ea out asap if
you ask me ;-)

On Thu, Jan 19, 2017 at 12:01 PM, Daniel Sun <re...@hotmail.com>
wrote:

> I verified that the new parser Parrot does not have the issue( GROOVY-4757
> <https://issues.apache.org/jira/browse/GROOVY-4757>  ), the following test
> case was added in the parrot branch. And I'll resolve the JIRA issue later.
>
> https://github.com/apache/groovy/commit/348465a1b193703c43aafeaabf2b28
> 6657d8493b
>
>
> Cheers,
> Daniel.Sun
>
>
>
>
> --
> View this message in context: http://groovy.329449.n5.
> nabble.com/The-order-of-modifiers-and-annotations-tp5737808p5737824.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.
>

Re: The order of modifiers and annotations

Posted by Daniel Sun <re...@hotmail.com>.
Thanks :)



在 "Marcin Erdmann [via Groovy]" <ml...@n5.nabble.com>,2017年1月20日 下午5:09写道:

Awesome!

On Thu, Jan 19, 2017 at 11:01 AM, Daniel Sun <[hidden email]> wrote:
I verified that the new parser Parrot does not have the issue( GROOVY-4757
<https://issues.apache.org/jira/browse/GROOVY-4757>  ), the following test
case was added in the parrot branch. And I'll resolve the JIRA issue later.

https://github.com/apache/groovy/commit/348465a1b193703c43aafeaabf2b286657d8493b


Cheers,
Daniel.Sun




--
View this message in context: http://groovy.329449.n5.nabble.com/The-order-of-modifiers-and-annotations-tp5737808p5737824.html
Sent from the Groovy Dev mailing list archive at Nabble.com.



________________________________
If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/The-order-of-modifiers-and-annotations-tp5737808p5737886.html
To unsubscribe from The order of modifiers and annotations, click here<http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5737808&code=cmVhbGJsdWVzdW5AaG90bWFpbC5jb218NTczNzgwOHwxMTQ2MjE4MjI1>.
NAML<http://groovy.329449.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>




--
View this message in context: http://groovy.329449.n5.nabble.com/The-order-of-modifiers-and-annotations-tp5737808p5737887.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: The order of modifiers and annotations

Posted by Marcin Erdmann <ma...@proxerd.pl>.
Awesome!

On Thu, Jan 19, 2017 at 11:01 AM, Daniel Sun <re...@hotmail.com>
wrote:

> I verified that the new parser Parrot does not have the issue( GROOVY-4757
> <https://issues.apache.org/jira/browse/GROOVY-4757>  ), the following test
> case was added in the parrot branch. And I'll resolve the JIRA issue later.
>
> https://github.com/apache/groovy/commit/348465a1b193703c43aafeaabf2b28
> 6657d8493b
>
>
> Cheers,
> Daniel.Sun
>
>
>
>
> --
> View this message in context: http://groovy.329449.n5.
> nabble.com/The-order-of-modifiers-and-annotations-tp5737808p5737824.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.
>

Re: The order of modifiers and annotations

Posted by Daniel Sun <re...@hotmail.com>.
I verified that the new parser Parrot does not have the issue( GROOVY-4757
<https://issues.apache.org/jira/browse/GROOVY-4757>  ), the following test
case was added in the parrot branch. And I'll resolve the JIRA issue later.

https://github.com/apache/groovy/commit/348465a1b193703c43aafeaabf2b286657d8493b


Cheers,
Daniel.Sun




--
View this message in context: http://groovy.329449.n5.nabble.com/The-order-of-modifiers-and-annotations-tp5737808p5737824.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: The order of modifiers and annotations

Posted by Andres Almiray <aa...@gmail.com>.
Yup, we've had this issue for a while
https://issues.apache.org/jira/browse/GROOVY-4757
Would be great to fix it with the Parrot parser.

On Thu, Jan 19, 2017 at 9:59 AM, Marcin Erdmann <ma...@proxerd.pl>
wrote:

> Sorry for stealing the thread, but there is one annoying thing that
> relates to parsing modifiers in Groovy. Is there any chance to fix modifier
> being mandatory for methods with generic signatures in Parrot? I.e. this is
> now invalid:
>
> <T> T foo(T bar)
>
> and has to be written like this to be parsed:
>
> public <T> T foo(T bar)
>
> Is there a reason for the modifier to be required in that case other than
> problems with parsing?
>
> I'm happy to file an issue for this if that is indeed considered to be an
> issue. Please let me know which issue tracker I should use if that's the
> case.
>
> Marcin
>
> On Thu, Jan 19, 2017 at 8:22 AM, Daniel Sun <re...@hotmail.com>
> wrote:
>
>> > def is by now to be thought of as an alias for Object
>> OK. I see. Thanks :)
>>
>>
>> Cheers,
>> Daniel.Sun
>>
>>
>>
>> --
>> View this message in context: http://groovy.329449.n5.nabble
>> .com/The-order-of-modifiers-and-annotations-tp5737808p5737813.html
>> Sent from the Groovy Dev mailing list archive at Nabble.com.
>>
>
>

Re: The order of modifiers and annotations

Posted by Marcin Erdmann <ma...@proxerd.pl>.
Sorry for stealing the thread, but there is one annoying thing that relates
to parsing modifiers in Groovy. Is there any chance to fix modifier being
mandatory for methods with generic signatures in Parrot? I.e. this is now
invalid:

<T> T foo(T bar)

and has to be written like this to be parsed:

public <T> T foo(T bar)

Is there a reason for the modifier to be required in that case other than
problems with parsing?

I'm happy to file an issue for this if that is indeed considered to be an
issue. Please let me know which issue tracker I should use if that's the
case.

Marcin

On Thu, Jan 19, 2017 at 8:22 AM, Daniel Sun <re...@hotmail.com> wrote:

> > def is by now to be thought of as an alias for Object
> OK. I see. Thanks :)
>
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context: http://groovy.329449.n5.
> nabble.com/The-order-of-modifiers-and-annotations-tp5737808p5737813.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.
>

Re: The order of modifiers and annotations

Posted by Daniel Sun <re...@hotmail.com>.
> def is by now to be thought of as an alias for Object
OK. I see. Thanks :)


Cheers,
Daniel.Sun



--
View this message in context: http://groovy.329449.n5.nabble.com/The-order-of-modifiers-and-annotations-tp5737808p5737813.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: The order of modifiers and annotations

Posted by Jochen Theodorou <bl...@gmx.org>.

On 19.01.2017 08:22, Daniel Sun wrote:
> Should we check the redundant modifiers? e.g.
>
> *Current*
> class A {
>     private def a  // def is redundant. IMHO, I really don't like it...
> }
>
> *Suggested*
> class A {
>     private a
> }

def is by now to be thought of as an alias for Object. In that sense it 
is correct to do "private def a" as it is correct to do "private Object a"

bye Jochen

Re: The order of modifiers and annotations

Posted by Daniel Sun <re...@hotmail.com>.
Should we check the redundant modifiers? e.g.

*Current*
class A {
    private def a  // def is redundant. IMHO, I really don't like it...
}

*Suggested*
class A {
    private a 
}

Cheers,
Daniel.Sun



--
View this message in context: http://groovy.329449.n5.nabble.com/The-order-of-modifiers-and-annotations-tp5737808p5737809.html
Sent from the Groovy Dev mailing list archive at Nabble.com.

Re: The order of modifiers and annotations

Posted by Jochen Theodorou <bl...@gmx.org>.

On 19.01.2017 08:13, Daniel Sun wrote:
> Hi all,
>
>        Currently the old parser allows mixing modifiers and annotations,
> e.g.
>
> *Current*
> @interface Test1 {}
> @interface Test2 {}
> @Test1 final @Test2 a
>
> *Suggested*
> @interface Test1 {}
> @interface Test2 {}
> @Test1 @Test2 final a

this looks right to me, though unless that gives a big advantage in the 
parser I would not do it.

>          In addition, the order of modifiers is arbitrary too, e.g.
>
> *Current*
> class A {
>     static final public a
> }
>
> *Suggested*
> class A {
>     public static final a
> }

that one I would not do

bye Jochen