Russel Winder's Website


Java Closures Get Groovy-er But...

Neal Gafter has released v0.3 of the Closures for Java proposal on his blog. The new syntax Neal et al. are proposing is:

{ int , int => int } plus = { int x , int y => x + y }

This is going to irritate people as they have to replicate the types of the parameters to the closure. Why not just let the compiler do the work and have:

{ int , int => int } plus = { x , y => x + y }

Of course, this is getting closer (or should that be closure!) to the Groovy syntax for closures:

plus = { x , y -> x + y }

or if you really have to have static types:

plus = { int x , int y -> x + y }

For now I shall stick with Groovy for closure-based programming.


Copyright © 2017 Russel Winder -