Re: [Poll] About supporting Java-like array

2018-05-02 Thread Daniel Sun
FYI, here is the poll result from twitter(https://twitter.com/daniel_sun/status/990544485196091395): 19 votes in total, 58% +1, 42% 0, 0% -1 Cheers, Daniel.Sun -- Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html

Re: [Poll] About supporting Java-like array

2018-05-01 Thread Jochen Theodorou
On 01.05.2018 19:27, Daniel Sun wrote: Hi Jochen, Supporting Java-like array is to copy & paste code in Java easily, e.g. experiment Java code in groovy console :-) I really don't think Groovy has to support everything from Java. I agree. If we could improve the compatibility be

Re: [Poll] About supporting Java-like array

2018-05-01 Thread Daniel Sun
Hi Jochen, Supporting Java-like array is to copy & paste code in Java easily, e.g. experiment Java code in groovy console :-) > I really don't think Groovy has to support everything from Java. I agree. If we could improve the compatibility between Groovy and Java, it would be good fo

Re: [Poll] About supporting Java-like array

2018-05-01 Thread Jochen Theodorou
Oh,and one important point... I really don't think Groovy has to support everything from Java. On 01.05.2018 17:20, Jochen Theodorou wrote: On 01.05.2018 16:26, MG wrote: I think we should do this, for cases where the rewards of adhering to idiomatic Groovy are less obvious or it might be mis

Re: [Poll] About supporting Java-like array

2018-05-01 Thread Jochen Theodorou
On 01.05.2018 16:26, MG wrote: I think we should do this, for cases where the rewards of adhering to idiomatic Groovy are less obvious or it might be missed that there even _is_ an idiomatic Groovy way to do things (I have heard some people were not aware that array initialization without "as"

Re: [Poll] About supporting Java-like array

2018-05-01 Thread MG
A codenarc rule would be a great first option. Cheers, mg Ursprüngliche Nachricht Von: Paul King mailto:pa...@asert.com.au>> Datum: 30.04.18 00:29 (GMT+01:00) An: users@groovy.apache.org <mailto:users@groovy.apache.org&

Re: [Poll] About supporting Java-like array

2018-05-01 Thread MG
I have created the issue: https://issues.apache.org/jira/projects/GROOVY/issues/GROOVY-8566 Feel free to comment on the "less lenient for static compilation case ?" question: "An additonal question would be, whether in the static case the automatic conversion of the RHS expression to fit the L

Re: [Poll] About supporting Java-like array

2018-04-30 Thread Paul King
he Nachricht > Von: Paul King > Datum: 30.04.18 01:51 (GMT+01:00) > An: users@groovy.apache.org > Betreff: Re: [Poll] About supporting Java-like array > > > > On Mon, Apr 30, 2018 at 9:10 AM, mg wrote: > >> I would propose the Groovy compiler issue a warnin

Re: [Poll] About supporting Java-like array

2018-04-30 Thread mg
avoid Groovy becoming a Babylonian-syntax-language like e.g. Ruby... Cheers,mg Ursprüngliche Nachricht Von: Paul King Datum: 30.04.18 01:51 (GMT+01:00) An: users@groovy.apache.org Betreff: Re: [Poll] About supporting Java-like array On Mon, Apr 30, 2018 at 9:10 AM, mg

Re: [Poll] About supporting Java-like array

2018-04-30 Thread mg
ng Datum: 30.04.18 05:18 (GMT+01:00) An: users@groovy.apache.org Betreff: Re: [Poll] About supporting Java-like array That sounds like a limitation we'd like to remove when using @CompileStatic. Want to create a Jira? Cheers, Paul. On Mon, Apr 30, 2018 at 12:39 PM, MG wrote:

Re: [Poll] About supporting Java-like array

2018-04-29 Thread Paul King
That sounds like a limitation we'd like to remove when using @CompileStatic. Want to create a Jira? Cheers, Paul. On Mon, Apr 30, 2018 at 12:39 PM, MG wrote: > Hi Daniel, > > I did a quick check and it works with dynamic Groovy, but is rejected > under static compilation: > > @Test@Ignorevoid a

Re: [Poll] About supporting Java-like array

2018-04-29 Thread MG
Hi Daniel, I did a quick check and it works with dynamic Groovy, but is rejected under static compilation: @Test @Ignore void arrayFromListLiteral() { int[] a0 = [1,2,3] int[][] aa0 = [[1,2,3],[4,5,6]] int[][][] aaa0 = [[[1],[2],[3]],[[4],[5],[6]]] int[][][] aaa1 = [[1,2,3],[4,5,6]]

Re: [Poll] About supporting Java-like array

2018-04-29 Thread Daniel Sun
Hi mg, As far as I remember, two dimensional array like`int[][] a = [[1, 2, 3], [4, 5, 6]]` will go wrong in the Groovy style. Cheers, Daniel.Sun -- Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html

Re: [Poll] About supporting Java-like array

2018-04-29 Thread Paul King
he Nachricht > Von: Paul King > Datum: 30.04.18 00:29 (GMT+01:00) > An: users@groovy.apache.org > Betreff: Re: [Poll] About supporting Java-like array > > The preferred Groovy syntax would probably still remain: > > int[] fibs = [1, 1, 2, 3, 5, 8] > > Che

Re: [Poll] About supporting Java-like array

2018-04-29 Thread Keith Suderman
Ursprüngliche Nachricht > Von: Paul King > Datum: 30.04.18 00:29 (GMT+01:00) > An: users@groovy.apache.org > Betreff: Re: [Poll] About supporting Java-like array > > The preferred Groovy syntax would probably still remain: > > int[] fibs = [1, 1, 2

Re: [Poll] About supporting Java-like array

2018-04-29 Thread mg
the Groovy compiler issue a warning to change the array initialization from Java- to Groovy-style then...Cheers,mg Ursprüngliche Nachricht Von: Paul King Datum: 30.04.18 00:29 (GMT+01:00) An: users@groovy.apache.org Betreff: Re: [Poll] About supporting Java-like array The prefer

Re: [Poll] About supporting Java-like array

2018-04-29 Thread Paul King
Yes, what you suggested is supported and indeed the preferred way. The `as int[]` is only needed if you have def at the front, e.g.: def fibs = [1, 1, 2, 3, 5, 8] as int[] Cheers, Paul. On Mon, Apr 30, 2018 at 7:54 AM, Keith Suderman wrote: > I am always +1 on supporting Java syntax when pract

Re: [Poll] About supporting Java-like array

2018-04-29 Thread Paul King
The preferred Groovy syntax would probably still remain: int[] fibs = [1, 1, 2, 3, 5, 8] Cheers, Paul. On Mon, Apr 30, 2018 at 7:17 AM, MG wrote: > After thinking about this some more for the last weeks > +1 with asterisk > from my side: > > 1) I am always for being as Java compatible as possi

Re: [Poll] About supporting Java-like array

2018-04-29 Thread Keith Suderman
I am always +1 on supporting Java syntax when practical. > On Apr 29, 2018, at 5:17 PM, MG wrote: > > 2) I feel { { } } being interpreted as an array containing an empty closure > is confusing, i.e. not least surprise. I would rather not see it cut it so > close with regards to what the Parr

Re: [Poll] About supporting Java-like array

2018-04-29 Thread MG
After thinking about this some more for the last weeks +1 with asterisk from my side: 1) I am always for being as Java compatible as possible (though I see that this might not be feasible in all cases in the future, due to Java changing at a much faster pace and with more syntax changes now tha

Re: [Poll] About supporting Java-like array

2018-04-29 Thread Paul King
+1 For completeness, I added some more details about the breaking changes and workarounds into the issue - included below for easy reading. Cheers, Paul. = Groovy currently "promotes" a singleton instance of an object into an array for assignments, e.g.: Integer[] nums = 42 ass

[Poll] About supporting Java-like array

2018-04-29 Thread Daniel.Sun
Hi all, As we all know, Java array is one of features widely applied in Java projects. In order to improve the compatibility with Java(Copy & Paste). The PR[1] will make Groovy support java-like array and make the differences[2] with Java less and less, e.g. *One-Dimensional array* ``` Strin