Say I need some very special multiplication operator. It may be implemented in following macro:
macro @<<!(op1, op2) { <[ ( $op1 * $op2 ) ]> }
And I can use it like
def val = 2 <<! 3
And its work.
But what I really want is some ‘english’-like operator for the DSL Im developing now:
macro @multiply(op1, op2) { <[ ( $op1 * $op2 ) ]> }
and if I try to use it like
def val = 2 multiply 3
compiler fails with ‘expected ;’ error
What is the problem? How can I implement this infix-format macro?
Straight from the compiler source code:
You need to sprinkle OperatorAttributes around and it will work. Btw, OperatorAttribute is defined as follows: