Hi Matt, We could look at expanding defer further but given Groovy has try/finally, try-with-resources, and withCloseable, numerous cases where you'd use it in Go aren't needed here. That's not to say it wouldn't still be useful in some additional places.
The tricky thing outside an async scope in Groovy is picking the desired semantics. Would a defer inside a closure attach to the closure, the enclosing method, or the block? Closures blur "function scope" in a way Go doesn't have to deal with, and whichever answer we picked would surprise someone. Inside an async closure there's a crisp, defensible answer: the async task. We could look at this further, but honestly, it's probably a Groovy 7 feature. I just tried using defer outside an async scope and it yields a pretty ugly MissingPropertyException. This is accurate but possibly puzzling for new users. It is quite possible that others also share your expectations, we could certainly look at adding a dedicated error message for that case during the Groovy 6 timeframe. Cheers, Paul. On Tue, Aug 11, 2026 at 9:17 AM Matt M <[email protected]> wrote: > > Thanks Paul! > > It might be too late, however, I wondered if there is still time to > provide some feedback on Groovy 6? Since beta1 came out the other day, I > have been finally using it and playing around with it and had a few > thoughts. > > The primary surprise was around the `defer` keyword. This is something I > was eagerly looking forward to. One of the expectations I had going into > it, given my reading of the Groovy 6 blog on Async/Await and the notes, > is that it would work like Go’s defer keyword. However, that doesn’t > appear to be the case. It appears to be exclusive to async/await code. > > Is there a semantic reason or design goal for not having it work for > both use cases (async/await code and like Go’s defer)? > > I already tinkered with adding support for it to work in any context and > act like Go’s defer instead. > > However, I figured I would ask if there was perhaps a larger design goal > or vision that perhaps explains why it doesn’t already do that. > > Thanks, > Matt > > ------ Original Message ------ > From "Paul King" <[email protected]> > To [email protected] > Date 8/10/2026 6:37:41 AM > Subject Re: [ANNOUNCE] Apache Groovy 6.0.0-beta-1 Released > > > > > > >I'll try to do 6.0.0-beta-2 (and 5.1.0) later in the week - still a > > > >few PRs to finish reviews for. > > > > > > > >Cheers, Paul. > > > > > > > >On Wed, Aug 5, 2026 at 7:27 AM Paul King <[email protected]> wrote: > >> > >> > >> > >> Thanks everyone for the great team effort in getting the Groovy 6 > >> > >> beta-1 release ready. The release is out and I have created beta-2 in > >> > >> Jira. I think we are feature complete with Groovy 6 and we won't get > >> > >> further feedback from some parts of our ecosystem until we get 6 to > >> > >> GA. So my plan is to rename beta-2 to RC-1 before the next release IF > >> > >> we only have bug fixes and minor or opt-in improvements. I'd also like > >> > >> to release sooner rather than later - maybe kicking off in a week or > >> > >> two. But we'll do a beta-2 if we need it - there are some pending PRs > >> > >> that might warrant a beta-2. > >> > >> > >> > >> Cheers, Paul. > >> > >> > >> > >> On Tue, Aug 4, 2026 at 4:40 PM Paul King <[email protected]> wrote: > >> > >> > > >> > >> > Dear community, > >> > >> > > >> > >> > The Apache Groovy team is pleased to announce version 6.0.0-beta-1 of > >> > >> > Apache Groovy. > >> > >> > Apache Groovy is a multi-faceted programming language for the JVM. > >> > >> > Further details can be found at the https://groovy.apache.org website. > >> > >> > > >> > >> > This is a pre-release of a new version of Groovy. > >> > >> > We greatly appreciate any feedback you can give us when using this > >> version. > >> > >> > > >> > >> > This release includes 88 bug fixes/improvements as outlined in the > >> changelog: > >> > >> > > >> https://issues.apache.org/jira/secure/ReleaseNote.jspa?projectId=12318123&version=12357232 > >> > >> > > >> > >> > Sources, convenience binaries, downloadable documentation and an SDK > >> > >> > bundle can be found at: https://groovy.apache.org/download.html > >> > >> > We recommend you verify your installation using the information on that > >> page. > >> > >> > > >> > >> > Jars are also available within the major binary repositories. > >> > >> > > >> > >> > We welcome your help and feedback and in particular want > >> > >> > to thank everyone who contributed to this release. > >> > >> > > >> > >> > For more information on how to report problems, and to get involved, > >> > >> > visit the project website at https://groovy.apache.org/ > >> > >> > > >> > >> > Best regards, > >> > >> > > >> > >> > The Apache Groovy team. >
