4 ms·
> As you may already know, there are 3 kinds of operators calling-notations: prefix (+ 3 5), infix (3 + 5), and postfix (3 5 +) There’s more than that; Raku, f
by dragonwriter 5y ago
> As you may already know, there are 3 kinds of operators calling-notations: prefix (+ 3 5), infix (3 + 5), and postfix (3 5 +)
There’s more than that; Raku, for instance, recognizes two more classes: circumfix (pair of symbols defining operator surrounds operands) and postcircumfix operators (like circumfix, but with an additional first operand outside of a preceding the paid of symbols), and lets you define new operators in any of the five notational classes.
- bradrn 5y agoIt goes further. Agda allows mixfix operators [0], which allows expressions to be arbitrarily interleaved with names and symbols, e.g.: if_then_else_ : {A : Set} → Bool → A → A → A if true then x else y = x if false then x else y = y [0] https://agda.readthedocs.io/en/v2.6.0.1/language/mixfix-operators.html https://agda.readthedocs.io/en/v2.6.0.1/language/mixfix-oper...
- agumonkey 5y agoHey that's lifted from Smalltalk isn't it ?
- dragonwriter 5y agoSmalltalk has functions with keyword arguments that look kind of like mixfix operators.
- travisgriggs 5y agoI miss keyword syntax. It has its warts, but I liked the clarity better than the whole funarg() list mess.
- agumonkey 5y agofunny, googling mixfix taught me racket also had something for it https://docs.racket-lang.org/mixfix/ https://docs.racket-lang.org/mixfix/
- munificent 5y agoThere's also mixfix where the operators are interleaved between the arguments, of which there are more than two. The well-known one is C's conditional operator: a ? b : c This is a single operation `?:` that takes operands a, b, and c.
- account42 5y agoExcept that the ternary operator in C and C++ is not really an operator but a control flow construct.
- HelloNurse 5y agoIt's an operator because it's functional (although often with side effects): three expressions go in and one expression goes out. Control flow constructs deal with statements instead.
- munificent 5y agoIt's an operator in the syntactic sense in the same way that "=", ".", and "||" are all operators.
- agumonkey 5y agoSome examples https://docs.raku.org/language/operators#Operator_classification https://docs.raku.org/language/operators#Operator_classifica... ps: we're going back to APL it seems