On 06/16/2014 07:03 PM, Sebastian Gesemann wrote:
Good example! I think even with scalar multiplication/division for
bignum it's hard to do the calculation in-place of one operand.

Each bignum can carry with it some extra space for this purpose.


Suppose I want to evaluate a polynomial over "BigRationals" using
Horner's method:

   a + x * (b + x * (c + x * d))

What I DON'T want to type is

   a + x.clone() * (b + x.clone() * (c + x.clone() * d))

But apparently you want to type

a.inplace_add(x.clone().inplace_mul(b.inplace_add(x.clone().inplace_mul(c.inplace_add(x.clone().inplace_mul(d))))))

Because that's the alternative you are suggesting to people who want to benefit from move semantics. Why would you deliberately set up a situation where less efficient code is much cleaner to write? This hasn't been the choice made by Rust in the past (consider the overflowing arithmetic getting sugar, but the non-overflowing one not).

-SL

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to