OxL Reference

kw infixl

Contextual keyword — operator declaration (§5.3)

The list of words: §1.4

Syntax

ebnf
Operator    = "operator" OpSymbol [ Generics ] "(" Params ")" "->" Type
              ( ( "infixl" | "infixr" | "infix" ) IntLit | "prefix" ) ( Block | "=>" Expr ) ;

Grammar: App. A

Defined in

Examples

oxl
operator <|> <T>(a: Parser<T>, b: Parser<T>) -> Parser<T>  infixl 3 => a.orElse(b)
operator ~~ (s: str, re: Regex) -> bool                      infix 4 => re.matches(s)
operator ^^ (a: f64, b: f64) -> f64                          infixr 12 => a.pow(b)
operator ¬ (b: Bits) -> Bits                                prefix => b.invert()

— 5.3 Overloading and user-defined operators

Related diagnostics

not-callable, not-overloadable, operator-decl, range-not-iterable

See also