Why is normal function invocation syntax allowed for infix functions?


#1

Allowing only infix notation would result in more uniform code. Also, the question “can/should I use infix notation for this function” would be answered automatically by tooling. Currently, it’s easy to overlook that a function is declared as infix.


#2

I think they were just copying Scala, which allows this behavior because it doesn’t make a distinction between infix and non-infix functions. You can write 4.+(2) just as foo anyFunction bar.

I agree uniformity here is good. Infix functions, I think, were meant to be essentially overloaded operators. Therefore, these functions should always be used as operators with infix notation. We shouldn’t declare non-operators as infix functions just to get rid of parentheses, and we shouldn’t write these operators with regular notation.

However, the IDE’s auto-complete should should infix function together with all functions after typing a period.


#3

There are corner-cases that require a generic syntax for all functions.

We should probably have an IDE inspection that encourages using the infix syntax