RE: About eliminating ambiguities of method call with closure argument

2020-03-28 Thread Milles, Eric (TR Tech, Content & Ops)
Is there any language that differentiates between one space and multiple whitespaces as a separator? My experience with C, C++, Java, Groovy, etc. is that any number of whitespaces are the same in terms of separation between tokens. In terms of parsing, you can't tell that an identifier is a m

RE: About eliminating ambiguities of method call with closure argument

2020-03-28 Thread Milles, Eric (TR Tech, Content & Ops)
Additionally, you are forcing the hand of users in terms of brace style if you require a closure to have its opening brace on the same line as the method call/name. -Original Message- From: Milles, Eric (TR Tech, Content & Ops) Sent: Saturday, March 28, 2020 10:20 AM To: dev@groovy.apa

Re: About eliminating ambiguities of method call with closure argument

2020-03-28 Thread MG
Hi Daniel, good to hear you seem to be well :-) Maybe I am missing something, but right now I don't see where writing a standalone closure in the code would makes sense, since it is not assigned to anything, and its creation has no side effects (?) The only application I can see is calling i

Re: About eliminating ambiguities of method call with closure argument

2020-03-28 Thread Jochen Theodorou
On 28.03.20 04:06, Daniel.Sun wrote: Hi all, Current groovy grammar of method call contains the following ambiguities, which are odd for users. For example, 1) method call with closure argument. That means the closure on the next line could be treated as argument of method `meth` ``` me

Re: About eliminating ambiguities of method call with closure argument

2020-03-28 Thread Remko Popma
> On Mar 29, 2020, at 0:19, Milles, Eric (TR Tech, Content & Ops) > wrote: > > Is there any language that differentiates between one space and multiple > whitespaces as a separator? My experience with C, C++, Java, Groovy, etc. is > that any number of whitespaces are the same in terms of s

RE: About eliminating ambiguities of method call with closure argument

2020-03-28 Thread Daniel.Sun
AFAIK, Groovy learned quite a few design ideas from many great language, e.g. Ruby. The optional parentheses feature was inspired by Ruby. The feature makes Groovy more friendly as DSL to users, but ambiguities introduced... Ruby has similar troubles(See the following link) https://stackoverflow

RE: About eliminating ambiguities of method call with closure argument

2020-03-28 Thread Daniel.Sun
Actually, we have already force some code style... But the code style is not unified: 2.5.8 parses the following code as a variable and a method call with closure argument ``` a | meth { p -> } ``` Let's add a newline. 2.5.8 parses the following code as binary expression and a closure ``` a | me

Re: About eliminating ambiguities of method call with closure argument

2020-03-28 Thread Daniel.Sun
Hi MG, Understood. Some spock code care the differences, e.g. the following code ``` modification| expected { Instant i, ZoneId z -> i.plusSeconds(1) } | defaultInstant.plusSeconds(1) ``` is expected to parsed as 2 binary expressions: ``` modification

Re: About eliminating ambiguities of method call with closure argument

2020-03-28 Thread Daniel.Sun
Hi Jochen, > How about unifying the other way around and make 1 and 2 both a method > call with a closure for meth? Groovy 3 has already unified them by accident... but some spock code is broken, so we are trying to find a way to please everyone ;-) ``` modification

Re: About eliminating ambiguities of method call with closure argument

2020-03-28 Thread Daniel.Sun
Nice catch ;-) Cheers, Daniel.Sun - Apache Groovy committer & PMC member Blog: http://blog.sunlan.me Twitter: @daniel_sun -- Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html