[rust-dev] std::num::pow() is inadequate / language concepts
pcwalton at mozilla.com
Fri Jul 25 10:04:37 PDT 2014
On 7/25/14 4:43 AM, SiegeLordEx wrote:
> Yes, I concur on most of these points and I've brought up some related
> points before. The operator overloading technique used by Rust is
> antithetical to efficient generic code. The core numeric traits and
> functions are currently designed only with built-in types in mind,
> causing BigInt (and others, e.g. matrices) to suffer. I don't know how
> to fix these things, but perhaps auto-ref and ad-hoc operator
> overloading (it works for Haskell, why not for Rust?) would be part of
> the solution.
Neither auto-ref or ad-hoc operator overloading would let you write a
generic function that calls `pow` and works optimally with both bigints
and ints. I think the only thing that would work is something like C++
ad-hoc templates, which is a road I don't want to go down.
> Ultimately, I suspect that function overloading (the Rust
> trait double-dispatch trick above may be sufficient with auto-ref) will
> be of critical importance. This problem is very under-appreciated and I
> hope this aspect of the language is not stabilized by 1.0.
I don't think we should be trying to solve it.
More information about the Rust-dev