On Mon, 26 May 2008, Patricia Shanahan wrote:
Wojtek wrote:
Arne VajhHj wrote :
Operators only make the code more readable for classic arithmetic.
Which is my point.
Maybe this subthread suggests a solution. Define, for example, an
interface Addable<T> with
T additionOperation(T o);
as its only method.
Analogising to multiplication, this is going to make it impossible to
write my Matrix class which can be multiplied any of a double, a
Vector, or another Matrix, because you can't implement multiple
instances of a generic interface. Well, you could, but you'd have to
do an instanceof switch inside additionOperation, or implement some
kind of ugly bounce dispatch.
Anyway, i'm not happy with this solution, although i appreciate and
strongly agree with its intent.
Good point. How about this modification?
Addable, Multipliable, etc. become marker interfaces. Suppose a is a
reference to Multipliable or a type implementing Multipliable. Then