amelentev / java-oo

Java Operator Overloading
http://amelentev.github.io/java-oo/
268 stars 31 forks source link

Reverse binary operator overload #25

Closed amelentev closed 9 years ago

amelentev commented 10 years ago

Use case - multiply double to Complex:

Complex a = new Complex(1.2, 2.3)
1.2*a

We can't add method multiply to double.

Solution: add method Complex#multiplyRev(double) This method will be used on second operand in cases where is no multiply method in left operand. So: 1.2 * a will be transformed to a.multiplyRev(1.2) This should work for every binary operator.

amelentev commented 9 years ago

Implemented in JavaC7,8-oo-plugin 0.5, idea-oo-plugin 0.4

yuemingl commented 9 years ago

That's really useful!

amelentev commented 9 years ago

Implemented in eclipse-oo-plugin 0.5