Re: Array initialisation
Patricia Shanahan wrote:
Joshua Cranmer wrote:
2. +,-,*,/ for near-numeric types (i.e., BigDecimal and BigInteger).
These have some potential commutativity concerns, so I wouldn't be too
miffed if this aspect were left out (although limited operator
overloading without touching basic mathematical operations is...
almost pointless).
How do you define "near-numeric"? All values of BigDecimal are numbers,
but double has non-numeric values, so BigDecimal seems nearer to numeric
than double to me.
Near-numeric is a catch-all for anything that could subclass Number and
other non-mathematic types (matrices, rings, etc.)
Mixed type operations can create a lot of complications, so I would
rather favor no implicit conversion for the overloaded operators.
My personal opinion for how it could be done would be to have something
like this:
public interface Addable<Addend,Sum> {
public Sum add(Addend o);
}
This would, however, require reified generics to be able to inherent
from the same interface with different generic parameters.
Why not "%"?
Um... it slipped my mind.
--
Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth