Operator overloading -- lets collect some use cases
smjg_1998 at yahoo.com
Sun Dec 28 15:57:51 PST 2008
> There's been some interesting discussion about operator overloading over
> the past six months, but to take the next step, I think we need to
> ground it in reality. What are the use cases?
> I think that D's existing opCmp() takes care of the plethora of trivial
> cases where <, >= etc are overloaded. It's the cases where the
> arithmetic and logical operations are overloaded that are particularly
> interesting to me.
> The following mathematical cases immediately spring to mind:
> * complex numbers
> * quaternions (interesting since * is anti-commutative, a*b = -b*a)
Not true. Quaternion multiplication does have the distinction of being
non-commutative in the general case, but anti-commutativity occurs in
only some special cases.
If you really want anti-commutativity, look at vectors under cross
Other unusual number systems: hypercomplex, biquaternions, octonions,
> * vectors
> * matrices
> * tensors
> * bigint operations (including bigint, bigfloat,...)
And possibly rational and Euclidean number types.
More information about the Digitalmars-d