Operator alias

Aliasing an existing operator to a new operator is one thing, but that new operator would have to abide by the existing grammar for operators. IIUC we're not likely to loosen that, and it's unlikely that we'll allow more things via operator aliases than we allow as plain operators.

  • Replace logical operators (&&, ||, !, etc.) with words like "and", "or", "not", and allow non-punctuation operators and infix functions: The operator and identifier grammars are intentionally partitioned in Swift, which is a key part of how user-defined overloaded operators are supported. Requiring the compiler to see the "operator" declaration to know how to parse a file would break the ability to be able to parse a Swift file without parsing all of its imports. This has a major negative effect on tooling support. While not needing infix support, not would need operator or keyword status to omit the parentheses as ! can, and not somePredicate()visually binds too loosely compared to !somePredicate().

Commonly Rejected Changes

5 Likes