Use this page to list use cases for AST-level macros in Groovy.
How do you want to use such macros? Show examples of their usage (without showing how they're implemented). Add to the bottom of the page.
The end-weight principle for natural languages says the longer stuff should be at the end of a sentence.
In Groovy/Java, while and if statements are usually heavy in the block/statement, and light in the condition.
When the statement/block is short and the condition long, it can be more readable to put the block last.
is transformed to:
We could use 'unless' and 'until' if using 'if' and 'while' caused problems.
When a long list of methods and/or fields have the same modifier/s,
it may be more readable to apply them to a whole block, eg:
triggered by the 'static' modifier of a field in a function.
Use names instead of symbols for operators, eg:
or change their names to something shorter, eg:
Forgoing curlies for all statements, making a statement and block equivalent always:
Enable fuller internationalization of Groovy, eg:
would convert to
if a Spanish option for Groovy was loaded.
Embed Java code within Groovy without quoting it,
and without needing to bind variables to the same name, ie, no binding.setVariable('i', i).
Many existing syntactic sugars could be re-implemented as macros in a standard macro library.
This might simplify the Antlr lexer/parser, enabling better maintenance of and extensions to it.
Eg, properties where: