29 February 2008

Tags: bgga closures groovy java

While there’s still no decision made on the integration of closure to the Java language (AFAIK), I think the BGGA proposal is the most promising candidate. I’m quite confident it will eventually be integrated to the language.

However, I was wondering about the syntax of the proposal, mainly because more and more programmers are using closures in Groovy. Basically, you’ll write a closure in Groovy like this :

{ x,y -> x+y }

In the BGGA proposal, the syntax is more verbose because Java is strongly typed :

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

Everything would be fine, but I was wondering about the separator, which can be confusing :

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

IMHO, it would be better if the proposal followed the syntax that’s getting known by more and more people, that is to say the Groovy one : replacing with

What do you think ?