groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Milles, Eric (TR Tech, Content & Ops)" <>
Subject Re: About polish the generics type syntax for closure
Date Wed, 13 Feb 2019 15:53:14 GMT
I agree Closure cannot be replaced/emulated completely.  And Function is not universally applicable
either.  But the universe of SAM types is much bigger than Function alone.

Your proposed syntax does not appear to cover much more than Function would.  And it would
introduce a lot of effort for reader and tool builder as well.  Groovy/Java developer already
has to be aware of closure literal and lambda literal syntax.  Your proposal adds a third
possibility when reader encounters "->" in source.

My general point is that there are a number of options that are available today.  Most can
also be used by Java or Kotlin code that offers some Groovy support/interop.  Groovy-only
syntax is not as widely applicable and would not be available for some time.  My opinion is
that there is little benefit to the new syntax and a lot of potential cost.

From: Daniel.Sun <>
Sent: Wednesday, February 13, 2019 8:07 AM
Subject: Re: About polish the generics type syntax for closure

Thanks for your suggestion.

If the argument type is Function and the parameter type is Closure, implicit
coerce will happen, thus the performance will be impacted somehow. Certainly
we can use native lambda to avoid the performance issue.
In addition, Function accepts only one parameter, a bit limited for general

In short, Closure can not be replaced completely.


Apache Groovy committer
Twitter: @daniel_sun

Sent from:

View raw message