Up until recently it was my understanding that two Scala statements below were interchangeable.
expr.op(arg1, arg2,...)
expr op (arg1, arg2,...)
But I've playing around with scala meta, looked at the resulting AST they generate,
Term.Apply(Term.Select(<exprTerm>, Term.Name("op")), Seq(<argTerm1>, <argTerm2>,...))
Term.ApplyInfix(<exprTerm>, Term.Name("op"), Nil, Seq(<argTerm1>, <argTerm2>,...))
and found a Nil
in the AST for the infix expression. Digging further, I found out that the infix option allows for type parameters:
expr op [Type1, Type2,...] (arg1, arg2,...)
In this context, I don't understand what purpose they'd serve. When would they be usefull? Why are they allowed on infix operations but not "apply-select" operations (expr.op(arg1, arg2,...)
)?