Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

The Groovy development team is happy to announce the joint release of Groovy 1.7.5 and Groovy 1.8-beta-2.

Both releases contain several bug fixes and minor improvements, but I'd particularly like to highlight two new features of Groovy 1.8-beta-2: closure composition and the new extended DSL capabilities. Make sure to have a look at the new features from the previous beta of 1.8 too, if you haven't had a chance so far.

If you recall your math lessons, function composition may be a concept you're familiar with. And in turn, closure composition is about that: the ability to compose closures together to form a new closure which chains the call of those closures. Here's an example of composition in action:

def plus2  = { it + 2 }
def times3 = { it * 3 }

def composed1 = plus2 << times3
assert composed1(3) == 11
assert composed1(4) == plus2(times3(4))

def composed2 = times3 << plus2
assert composed2(3) == 15
assert composed2(5) == times3(plus2(5))

// reverse composition
assert composed1(3) == (times3 >> plus2)(3)

To see more examples of closure composition and reverse composition, please have a look at our test case.

Groovy 1.8-beta-2 features the great work of our Google Summer of Code student, Lidia Donajczyk, who worked on an extension of the command expression notation (also known as GEP-3 / Extended Command Expressions). In a nutshell, Groovy allows you to omit dots and parentheses for chained methods calls, so that such calls look more like natural language sentences.

A few sentences this new DSL capability will allow you to write:

move left by 30.centimeters
sell 100.shares of MSFT
take 2.pills of chloroquinine in 6.hours

I've blogged about extended command expressions already, if you want to have some additional examples of sentences you can write, and you can have a look at the various examples published on the Groovy Web Console which also demonstrate how to construct such DSLs.

You can have a look at the JIRA release notes:

You can download those Groovy versions from the download area. And as usual, the artifacts will be sync'ed up with Maven's central repository.

Thanks a lot to everybody involved in those new releases.