[rust-dev] impl num::Zero and std::ops::Add error

Tupshin Harper tupshin at tupshin.com
Wed Apr 9 13:35:23 PDT 2014


Which is distinct from http://en.wikipedia.org/wiki/Identity_matrix
On Apr 9, 2014 4:31 PM, "Nick Ward" <ward.nickjames at gmail.com> wrote:

> http://en.wikipedia.org/wiki/Zero_matrix
> On 9 Apr 2014 21:26, "Tommi Tissari" <rusty.gates at icloud.com> wrote:
>
>> > On 09 Apr 2014, at 20:46, Kevin Ballard <kevin at sb.org> wrote:
>> >
>> > Why? Zero is the additive identity.
>>
>> Zero is _an_ additive identity for numbers, but not for vectors or
>> matrices.
>>
>> use std::slice::Items;
>> use std::iter::RandomAccessIterator;
>> use std::num::Zero;
>>
>> Items is a RandomAccessIterator, but a RandomAccessIterator is not an
>> Items. 0 is an additive identity, but an additive identity is not 0. You
>> can't assign a zero to a 2x2 matrix, and therefore this trait is
>> incorrectly named. The following just looks wrong:
>>
>> let m: Matrix = Zero::zero();
>>
>> > AdditiveIdentity is the only reasonable alternative, but that's a
>> mouthful of a name and I think changing the name to this would be more
>> confusing.
>>
>> Naming a trait something that it's not is even more confusing. I don't
>> think we should give an incorrect name to this trait on the grounds of the
>> correct name being longer. Just look at RandomAccessIterator.
>>
>> _______________________________________________
>> Rust-dev mailing list
>> Rust-dev at mozilla.org
>> https://mail.mozilla.org/listinfo/rust-dev
>>
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140409/6b65318e/attachment.html>


More information about the Rust-dev mailing list