>
>> I think you could experiment with this using a closure, since return
>> statements have this expression property already:
>>
>>
>>
>> final foo = ({ ->
>>
>> if(...) { ... }
>>
>> else if(...) { ... }
>>
>> else i
return statements have this expression property already:
final foo = ({ ->
if(...) { ... }
else if(...) { ... }
else if(...) { ... }
else { ... }
}())
*From:*mg [mailto:mg...@arscreat.com]
*Sent:* Wednesday, March 21, 2018 4:03 PM
*To:* dev@groovy.apache.org <mailto:dev@groovy.apach
))
>
>
>
>
>
> *From:* mg [mailto:mg...@arscreat.com <mg...@arscreat.com>]
> *Sent:* Wednesday, March 21, 2018 4:03 PM
> *To:* dev@groovy.apache.org
> *Subject:* Re: [RFE] Methods as expressions
>
>
>
> Having control flow statements as expressions in
ct:* Re: [RFE] Methods as expressions
Having control flow statements as expressions in Groovy would feel
pretty natural to me. I had always assumed there were reasons why this
was not supported, so I did not bring it up...
I currently use the simulated eval language extension I proposed for
that,
:03 PM
To: dev@groovy.apache.org
Subject: Re: [RFE] Methods as expressions
Having control flow statements as expressions in Groovy would feel pretty
natural to me. I had always assumed there were reasons why this was not
supported, so I did not bring it up...
I currently use the simulated e
od in Rust ?
Cheers,mg
Ursprüngliche Nachricht Von: David Dawson
<david.daw...@simplicityitself.com> Datum: 21.03.18 10:07 (GMT+01:00) An:
dev@groovy.apache.org Betreff: Re: [RFE] Methods as expressions
in Rust, control flow statements are expressions. Partly this was
in Rust, control flow statements are expressions. Partly this was done to
enable the lifetimes to be more concisely controlled, but its a nice
structure.
If done in groovy, this would work (toy example, picking the right payment
provider based on a property)
def provider = if(request.name ==
Am 21.03.2018 um 09:27 schrieb Cédric Champeau:
[...]
In any case, I was doubtful as you are here before actually using it in
Kotlin. After a few weeks, it became clear to me this syntax was both
more concise and more self-explanatory.
For me {} was always very clear, for {} starts a new
Another case is a method / function that returns a closure, would we allow
the syntax:
def m(String x, int y) = { x * y }
?
On Wed, Mar 21, 2018 at 3:46 AM, Daniel Sun wrote:
> Hi Cédric,
>
> If method throws exception, what does your proposed syntax look like?
>
It's funny to see arguments about compatibility with Java here. Groovy's
compatibility with Java is the promise that you can _almost_ copy and paste
Java code and it compiles in Groovy. Not the other way around ;)
In any case, I was doubtful as you are here before actually using it in
Kotlin.
LOL. thanks, I probably deserved that being thrown back at me :-)
I think that Jochen said it best "It seemed to be part of a bigger picture,
but the bigger picture is missing."
My CS background is on the weaker side, so I can't quite say what I want...
Apart from Groovy, the two languages that
Hi Cédric,
If method throws exception, what does your proposed syntax look like?
For example,
```
def m(String x, Integer y) throws IOException {
readSomeFile(..)
}
```
is equivalent to the following code?
```
def m(String x, Integer y) throws IOException = readSomeFile(..)
```
On 20.03.2018 17:16, David Dawson wrote:
To give an alternate take on the topic.
The best thing in Groovy when it first started gaining adoption was this
["hello"], "world"].collect {
it * 2
}.each { println it }
Utterly incompatible with Java, happily destroying its idioms.
Collection
On 20.03.2018 16:19, eric.mil...@thomsonreuters.com wrote:
Java syntax for a default method value is:
public@interfaceDelegate{
boolean*interfaces*() defaulttrue;
Is there really a need to introduce another form when the saving is
actially 0 characters (colon and equals vs open and close
ize named
> parameters?
>
>
>
> *From:* mg [mailto:mg...@arscreat.com]
> *Sent:* Tuesday, March 20, 2018 7:11 AM
> *To:* dev@groovy.apache.org
> *Subject:* Re: [RFE] Methods as expressions
>
>
>
> I agree with the proper functions in principle, but in this case it w
: Tuesday, March 20, 2018 7:11 AM
To: dev@groovy.apache.org
Subject: Re: [RFE] Methods as expressions
I agree with the proper functions in principle, but in this case it would be
"special syntax for a special, limited case" which to me is the (non desirable)
C# way of doing things...
I
Hi Cédric,
+1. I would like to hear what other groovy users say.
P.S. Your proposal should be not difficult to implement in Parrot parser.
Cheers,
Daniel.Sun
--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html
of making Groovy Kotlin compatible now
Ursprüngliche Nachricht Von: David Dawson
<david.daw...@simplicityitself.com> Datum: 20.03.18 13:00 (GMT+01:00) An:
dev@groovy.apache.org Betreff: Re: [RFE] Methods as expressions
I personally agree with Cedric, having the intent of &q
: Cédric Champeau <cedric.champ...@gmail.com>
> Datum: 20.03.18 12:23 (GMT+01:00)
> An: dev@groovy.apache.org
> Betreff: Re: [RFE] Methods as expressions
>
> Again that's a declaration of intent (if you put apart the fact that you
> can have style rules that force you to put t
atum: 20.03.18 11:41 (GMT+01:00) An:
dev@groovy.apache.org Betreff: [RFE] Methods as expressions
Hi,
One of the Kotlin features I really like is the short-hand notation for simple
expression methods:
class Foo {
fun truth(): Integer = 42
}
For example, in Groovy, you write:
@Controller
2:23 (GMT+01:00) An:
dev@groovy.apache.org Betreff: Re: [RFE] Methods as expressions
Again that's a declaration of intent (if you put apart the fact that you can
have style rules that force you to put the brackets on new lines).
When I write:
double surface(double x, double y) = x * y
It's
Ursprüngliche Nachricht
> Von: Cédric Champeau <cedric.champ...@gmail.com>
> Datum: 20.03.18 11:41 (GMT+01:00)
> An: dev@groovy.apache.org
> Betreff: [RFE] Methods as expressions
>
> Hi,
>
> One of the Kotlin features I really like is the sho
- Ursprüngliche Nachricht
> Von: Cédric Champeau <cedric.champ...@gmail.com>
> Datum: 20.03.18 11:41 (GMT+01:00)
> An: dev@groovy.apache.org
> Betreff: [RFE] Methods as expressions
>
> Hi,
>
> One of the Kotlin features I really like is the short-hand notation
: [RFE] Methods as expressions
Hi,
One of the Kotlin features I really like is the short-hand notation for simple
expression methods:
class Foo {
fun truth(): Integer = 42
}
For example, in Groovy, you write:
@Controller("/") class HelloController {
@Get("/hello/{name
lt;cedric.champ...@gmail.com> Datum: 20.03.18 11:41 (GMT+01:00) An:
dev@groovy.apache.org Betreff: [RFE] Methods as expressions
Hi,
One of the Kotlin features I really like is the short-hand notation for simple
expression methods:
class Foo {
fun truth(): Integer = 42
}
For example, in
I agree, that's the syntax I use for now. But I like the expression syntax
`=` because of the explicitness of the expression (it's a function which
value is ...). It's less about saving characters than it is about
expressing the intent.
2018-03-20 12:08 GMT+01:00 Andres Almiray
FYI you can also write it like
@Controller("/") class HelloController {
@Get("/hello/{name}")
String hello(String name) { "Hello $name" }
}
So you're only saving 2 characters (space and closing brace) by following
Kotlin/Scala syntax.
Cheers,
Andres
Yes, I would love this kind of thing
On 20 March 2018 at 10:41, Cédric Champeau
wrote:
> Hi,
>
> One of the Kotlin features I really like is the short-hand notation for
> simple expression methods:
>
> class Foo {
> fun truth(): Integer = 42
> }
>
> For example,
Hi,
One of the Kotlin features I really like is the short-hand notation for
simple expression methods:
class Foo {
fun truth(): Integer = 42
}
For example, in Groovy, you write:
@Controller("/") class HelloController {
@Get("/hello/{name}")
String hello(String name) {
29 matches
Mail list logo