I've run into times where a proc is most naturally expressed as an operator, for example, something like a signed modulus, or checking if a point is in a polygon defined by an array of points (as opposed to checking if the point is in that array). I know there's ways around most of these issues, but I do think it would be nice to have the backtick syntax define custom operators even if the proc name is not purely symbols. For example, this would make something like
func `sgnmod`(i : int, r : (int, int)) : int = # Implements a signed modulo
# logic here
echo 7 sgnmod (-1, 4) # This line would not work at the moment
possible
The problem is backticks mean "turn operators into identifiers" not "turn identifiers into operators" in Nim, unlike Haskell.
The operator behavior is tied to the parser so it is nontrivial, occasionally impossible to make operator behavior depend on things that use semantic checking, which happen after parsing, like function declarations.
The best we can do is add more predefined operators (like Julia), however going too far with this can easily cause problems. There is more discussion about this in https://forum.nim-lang.org/t/8754 but the original post is annoyingly hidden
TIL you can do infix unicode operators! Just one --experimental:unicodeOperators away. Then you can define an appropriate unicode operator like say "⊘":
proc `⊘`(a, b: int): int = a + b
1 ⊘ 2
Though editor support for Julia includes converting pseudo-latex names into unicode operators like \kronecker => ⊗.