Algol
MyVec MyVec::operator+(MyVec vec) { /* code */ }
Custom Operators from Scala Graph project:
1 ~ 2 % 5 Creates an edge with weight 5
~%#+ Create key-weighted labeled undirected edge
~%+# Create weighted key-labeled undirected edge
Make Array + Array mean bitwise xor of the elements via implicit conversion
implicit class ByteArrayOps(private val a1: Array[Byte]) extends AnyVal {
def + (a2: Array[Byte]): Array[Byte] =
(a1 zip a2).map { case (x, y) => (x^y).toByte }
}
You can alter the compiler:
Javac 7 has annotation processors
Javac 8 has plugins
& Artem Melentyev has: https://github.com/amelentev/java-oo
With plugins for Eclipse, IntelliJ, and NetBeans
- Changes the language.
- Precedence: no right solution for parsing.
E.g. We know how to parse
a + b * c
but how should we parse
a ¬ b " c
- But Java-OO is limited: no custom operators