How useful are infix operators in a programming language? Are they worth the extra complexity they provide? Can you provide any examples where infix operators are better suited to the problem that can't be handled by just overloading the normal operators?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
I think infix operators stem from mathematics.
is more readable to most people, than
because most people are familiar with mathematics.
Interesting enough in Haskell you can hop between infix and prefix. This is using the same funtion "(+)":
and this is using the same function "elem":
Computer languages are designed for humans not machines. And humans are more used to infix operators than pre or postfixes.
The only real reason for infix operators is that humans generally find them easier to read. This is largely due to two facts:
From a logical/machine perspective, infix operators don't really add any value and in some cases are a nuisance: