> Overloading Mul for matrix multiplication would be a mistake, since that 
> operator does not act the same way multiplication acts for scalars.

I think that one of the main reasons for overloading operators is not their 
genericity but their usage in the code.

    let a = Matrix::new(…);
    let x = Vector::new(…);
    let b = Vector::new(…);
    let result = a * x + b;

Looks much nicer than

    let result = a.times(x).plus(b);

In mathematical computations you usually use concrete types, and having 
overloadable operators just makes your code nicer to read.

That said, for mathematicians it is absolutely not a problem that 
multiplication for matrices works differently than for scalars.
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to