Re: operator overloading
Patricia Shanahan wrote:
Foo anyMethodIWant(Foo foo) {...}
This loses the property that I think may make this relatively
non-controversial, the requirement that the method be declared to be
From my personal perspective, you've already lost that, because an
interface can be added to any class. That's rather more abusable than
I'd prefer.
One root class, abstract or otherwise, is less abusable, in my opinion.
public abstract class AbstractNumber {
public abstract AbstractNumber multiply( AbstractNumber n );
public abstract AbstractNumber divide( AbstractNumber n );
// etc.
}
Now you can still abuse this and derive things from AbstractNumber that
really aren't abstract numbers, but that can't be helped. What you
can't do is something like:
class MyList extends AbstractList implements Addable {
// abuse city
}
So by using one root class, operator overloading can't be add willy
nilly to any class. It's confined to descendants of AbstractNumber (and
maybe something like AbstractMatrix).
I know those of you still debating this don't really agree with that,
I'm just waving my little not-so-much-operator-overloading flag around,
just to show it's still here. :)