In addition, mathematicians typically use the symbol '0' to refer to the additive identity of a ring anyway. On Apr 9, 2014 10:47 AM, "Kevin Ballard" <[email protected]> wrote:
> Why? Zero is the additive identity. It's only bad if you want to denote a > value that contains zeros that doesn't support addition, but that's only > bad because of a misconception that Zero should mean "a default value" when > we have Default for that. For reference, the Zero trait lives in std::num, > which should be a good indication that this is a property of numeric types. > > 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. > Someone who needs a numeric zero isn't going to go looking for > AdditiveIdentity, they're going to look for Zero. > > -Kevin > > On Apr 9, 2014, at 6:29 AM, Liigo Zhuang <[email protected]> wrote: > > Zero is a bad name here, it should be renamed or removed > 2014年4月9日 上午1:20于 "Kevin Ballard" <[email protected]>写道: > >> On Apr 7, 2014, at 1:02 AM, Tommi Tissari <[email protected]> wrote: >> >> On 07 Apr 2014, at 08:44, Nicholas Radford <[email protected]> >> wrote: >> >> I think the original question was, why does the zero trait require the >> add trait. >> >> If that was the original question, then my answer would be that >> std::num::Zero requires the Add trait because of the way it is >> specified: "Defines an additive identity element for Self". Then the >> question becomes: "why is Zero specified like that?", and I would answer: >> because then you can use it in generic algorithms which require their >> argument(s) to have an additional identity. >> >> >> If you want a zero value for a type that doesn't support addition, >> std::default::Default may be a good choice to use. Semantically, that >> actually returns the "default value" for a type instead of the "zero >> value", but in a type without addition, how do you define "zero value"? >> >> -Kevin >> >> _______________________________________________ >> Rust-dev mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/rust-dev >> >> > > _______________________________________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/listinfo/rust-dev > >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
