Open
Description
As someone who does a good amount with macros, one thing I find lacking is the ability to be DRY. There currently isn't a way (AFAIK) that allows encapsulating logic to be reused within different macros. I.e. if there is some piece of logic you need to do multiple times in a macro, you would have to duplicate it.
It would be a great addition to allow defining methods that can be used within macro code; I.e. that accept one or more ASTNode
s, and return an ASTNode
.
For example:
macro def foo(x : StringLiteral) : StringLiteral
"foo#{x}"
end
macro bar
{{ foo "x" }}
end
bar # => "foox"
This would allow common/complex logic to be defined once and reused throughout an application.