As it stands, the documentation doesn't say that `Mul` means commutative 
multiplication. Therefore it would be a mistake to write generic code that 
assumes that a type which implements `Mul` has commutative multiplication. 
Implementing `Mul` for two matrices would not be a mistake.

On 2014-06-17, at 14:34, SiegeLord <slab...@aim.com> wrote:

> On 06/16/2014 06:17 PM, Cameron Zwarich wrote:
>> On Jun 16, 2014, at 3:03 PM, Cameron Zwarich <zwar...@mozilla.com> wrote:
>> I stated the right case, but the wrong reason. It’s not for vectorization, 
>> it’s because it’s not easy to reuse the storage of a matrix while 
>> multiplying into it.
> 
> Overloading Mul for matrix multiplication would be a mistake, since that 
> operator does not act the same way multiplication acts for scalars. I.e. 
> you'd overload it, but passing two matrices into a generic function could do 
> very unexpected things if the code, e.g., relies on the operation being 
> commutative. Additionally, if your matrices contain the size in their type, 
> then some generic code wouldn't even accept them. Matrix scalar 
> multiplication is a better candidate for the Mul overload.
> 
> -SL
> _______________________________________________
> Rust-dev mailing list
> Rust-dev@mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to