Re: [PROPOSAL]Support conditional return

2020-07-30 Thread Jochen Theodorou
On 30.07.20 18:08, MG wrote: 1. Hiding a semantic "if" inside a "for"-loop syntax is not good, in my book - in C++ I would have introduced a "returnIf"-macro to make the intention clear in that case... ;-) 2. I was also thinking along the same line, but more like: if(it = goo(); a>6 && it>10) {

Re: [PROPOSAL]Support conditional return

2020-07-30 Thread MG
Alternative solutions are coming in hard & fast ;-) Applied to this specific problem, while clever, I feel that this suggestion would not express as clearly what is actually happening :-) Apart from that I would however like to have the ability to return from the/an enclosing method inside a c

Re: [PROPOSAL]Support conditional return

2020-07-30 Thread MG
In that case I would go back to Eric's suggestion, if we still feel we need a macro solution... :-) On 30/07/2020 01:10, Daniel Sun wrote: Hi mg, I like your idea, but it's hard for IDE to infer the type of `it` during we coding. ``` returnIf(a > 6 && it > 10) { goo() } ``` Cheers, Da

Re: [PROPOSAL]Support conditional return

2020-07-30 Thread MG
1. Hiding a semantic "if" inside a "for"-loop syntax is not good, in my book - in C++ I would have introduced a "returnIf"-macro to make the intention clear in that case... ;-) 2. I was also thinking along the same line, but more like: if(it = goo(); a>6 && it>10) { return it } How does the r

Re: [PROPOSAL]Support conditional return

2020-07-30 Thread MG
Hi Daniil, 1. without "??:", that only works for the case where Groovy-truth is applicable for the return value of doChooseMethod 2. I find the [null, Character.TYPE, Integer.TYPE]-iteration idea clearer / more DRY here irrespective of that :-) 3. Why _is_ "throw" not considered an expressi

RE: [PROPOSAL]Support conditional return

2020-07-30 Thread Milles, Eric (TR Technology)
> for (goo(); a>6 && it>10;) {return} Actually my first take on the macro implementation was to create a for statement because it provides a scope for a temp variable and supports a statement. Then I discovered that macro methods must return an expression... -Original Message- From: Jo

Re: [PROPOSAL]Support conditional return

2020-07-30 Thread Daniil Ovchinnikov
I agree with Johan here, I’d even go ahead and write something like: ``` def chooseMethod(String methodName, Object[] arguments) { final methodChosen = doChooseMethod(methodName, arguments) ?: doChooseMethod(methodName, adjustArguments(arguments.clone(), Character.TYPE)) ?: doChoo

Re: [PROPOSAL]Support conditional return

2020-07-30 Thread Jochen Theodorou
On 30.07.20 01:10, Daniel Sun wrote: Hi mg, I like your idea, but it's hard for IDE to infer the type of `it` during we coding. ``` returnIf(a > 6 && it > 10) { goo() } ``` long time ago I made the suggestion of a ClosureList based on the classic for: "(" expr (";" expr)+ ")". It got