[erlang-questions] Infix function and user-defined operators
Thu Jan 17 10:22:31 CET 2019
On Wed, Jan 16, 2019 at 8:46 PM <empro2@REDACTED> wrote:
> > >> What other
> > >> use-case/applications you might imagine for infix
> > >> notation?
> Does infix-notation carry any inherent superiority apart
> from people being used to infix-expressions?
Ah, this is the rub.
As an old-time LISP and Scheme aficionado, I find this obsession with
infix notation weird. The generic function call syntax, whether you
prefer f(X, Y) or (f X Y), is unambiguous and more flexible since it
allows different arities.
Infix operators are tolerable when they're few and fixed by the
language. Add user-defined ones, overloading, user-defined precedence
and associativity, and you get a recipe for unreadable code. No
About the only use for non-prefix notation I can find is for compound
literals, where it's useful to be able to say e.g. [X, Y | Z] in
_both_ pattern-matching and expression evaluation contexts. (One
thing I think LISP got wrong is that the syntax for a compound literal
wasn't also the syntax for an expression evaluating to that literal.
But I digress.)
More information about the erlang-questions