Re: [GEP] About supporting Java-Like array literal

2018-04-26 Thread Daniel Sun
Hi Paul,

  Here is the PR to make Groovy support java-like array:
https://github.com/apache/groovy/pull/691

Cheers,
Daniel.Sun



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


Re: [GEP] About supporting Java-Like array literal

2018-04-16 Thread Paul King
Well, it's fine to "refine it later" on the branch. I don't think we want
it in master unless we exactly know what breaking changes like above might
be involved.

Cheers, Paul.

On Mon, Apr 16, 2018 at 8:35 PM, Daniel Sun  wrote:

> Hi Paul,
>
> The Parrot parser on the `phoenix` branch can handle nested array
> literals, but it parses it as list currently, we can refine it later ;-)
>
> ```
> Closure[] y = { {-> 1 + 1 } }
> assert y[0].call().call() == 2
> ```
> > is the second ".call()" no longer needed?
> yes.
>
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
>


Re: [GEP] About supporting Java-Like array literal

2018-04-16 Thread Daniel Sun
Hi Paul,

The Parrot parser on the `phoenix` branch can handle nested array
literals, but it parses it as list currently, we can refine it later ;-)

```
Closure[] y = { {-> 1 + 1 } }
assert y[0].call().call() == 2
```
> is the second ".call()" no longer needed?
yes.


Cheers,
Daniel.Sun



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


Re: [GEP] About supporting Java-Like array literal

2018-04-16 Thread Paul King
The following examples, although a little strange, are currently supported
in master:

Closure[] x = { -> 1 + 1 }
assert x[0].call() == 2

Closure[] y = { {-> 1 + 1 } }
assert y[0].call().call() == 2

Are both supported in your branch or for the second example, is the second
".call()" no longer needed?


On Mon, Apr 16, 2018 at 7:00 PM, Daniel Sun  wrote:

> Hi all,
>
>The new parser Parrot has supported some code like `int[] a = new
> int[] {1, 2, 3}`. In order to make Groovy compatible with Java better(copy
> &
> paste code and run well), I propose to support Java-Like array literal
> further, i.e. supporting some code like`int[] a = {1, 2, 3}`.  I
> experimented the new feature last weekend, it works well on the `phoenix`
> branch of `danielsun1106/groovy-parser` project[1].
>
>As for some ambiguous scenario, e.g. `def a = { 1 }`, it is still
> parsed as closure, but if the array type is specified `int[] a = { 1 }`, it
> will be parsed as int array.
>
>Any thoughts?
>
> Cheers,
> Daniel.Sun
> [1] https://github.com/danielsun1106/groovy-parser/tree/phoenix
>
>
>
>
> --
> Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
>