P
Patricia Shanahan
Wojtek said:Arne Vajhøj wrote :
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.
If BigInteger implemented Addable<BigInteger> the compiler would replace
a+b for BigInteger a and b with a.additionOperation(b).
This is similar to the idea of allowing special for-loop syntax for
iteration over the elements of an Iterable Object.
The hope is that having to call the method "additionOperation" will make
people think twice about using it for anything other than addition.
Of course, one could go on to define Subtractable, Multipliable, and
Dividable. If the decision were made to allow [] indexing, there would
be an interface Indexable with methods get() and set(). Perhaps
there should also be an interface LongIndexable, with get and set
methods that use longs instead of ints.
Patricia