The syntax without parentheses works only for some operators; it does not work e.g. for `&`, since `&` is also a prefix operator.
There are also some contexts where parsing is ambiguous without the parentheses, e.g. expressions such as `[+ + +]`. This could be an array literal with three functions `[(+) (+) (+)]`, or could be an addition taking functions as argument `[(+) + (+)]` or `[(+)((+), (+))]`. -erik On Tue, Apr 5, 2016 at 9:13 AM, Didier Verna <did...@didierverna.net> wrote: > > Hi, > > the user manual says this (VARIABLES section): > > "Operators like + are also valid identifiers, but are parsed > specially. In some contexts, operators can be used just like variables; > for example (+) refers to the addition function, and (+) = f will > reassign it." > > This looks like Haskell's bridge between the infix and prefix > syntax. However, it seems that contrary to what the manual says, you > don't need the parenthesis, i.e. I can do just x = f. So is there a real > reason for using (+) ? > > Also another question: is it possible, as in Haskell, to define new > infix operators, or are you restricted[1] to the built-in ones ? > > Thanks. > > > Footnotes: > [1] by "restricted" here, I don't mean to say that there are too few of > them; I'm aware the unicode ones are available. > > -- > Resistance is futile. You will be jazzimilated. > > Lisp, Jazz, Aïkido: http://www.didierverna.info -- Erik Schnetter <schnet...@gmail.com> http://www.perimeterinstitute.ca/personal/eschnetter/