[rust-dev] Fwd: &self/&mut self in traits considered harmful(?)

SiegeLord slabode at aim.com
Tue Jun 17 04:34:24 PDT 2014

On 06/16/2014 06:17 PM, Cameron Zwarich wrote:
> On Jun 16, 2014, at 3:03 PM, Cameron Zwarich <zwarich at 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.


More information about the Rust-dev mailing list