Hi! I'm very excited about reviving gcontracts in Groovy 4. However, I will like to suggest a few things.
I believe that besides annotations, it would be great to add explicit Design-By-Contract API too. It might even be implemented like global methods (maybe via Groovy macro mechanism). Here are some reasons as I see them: - API can be more convenient if checking expressions are more complex - IDE support should be better than for expressions in annotations. - API can, for example, support Hamcrest matchers (sometimes they are more apparent and explicit than boolean expressions) - API can support convenient pass-through methods which return checked object when it is valid (see valid4j library) - direct require(), ensure(), and maybe neverGetHere() (from valid4j) APIs are placed in methods code without requiring mental translation about the point where annotation expressions are executed - depending on implementation, direct API can be more code coverage friendly, which is very important either for asserts (not covered well by Jacoco, for example) or DBC APIs - On the negative side, annotations might be more apparent and are displayed in Groovydoc. That last point maybe can be addressed by some Groovy and Groovydoc magic, I guess. I found varify4j (http://www.valid4j.org/, http://www.valid4j.org/concepts.html) being an excellent example of an API based DBC library. Of course, being a pure Java library, it lacks some Groovy magic like better error messages that should include real expressions used in code. Please, take into consideration that I didn't yet look at Groovy 4. I only read release notes. Tnx, Damir Murat