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: [GEP] About supporting Java-Like array literal
Date Mon, 16 Apr 2018 09:51:21 GMT
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 <realbluesun@hotmail.com> 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
>

Mime
View raw message