I think a reasonable middle ground is to have checked operators that look a little funny. Kind of like swift, but in reverse:
> malloc((number_of_elements +~ 12) *~ size_of::<int>()) Where adding a ~ to the end of an operator makes it check for overflow. This would certainly look nicer than stuff like: > malloc(number_of_elements.checked_add(12).checked_mul(size_of::<int>())) lying around in low level data structures code. It also keeps the default fast, which is very important. - Clark On Sun, Jun 22, 2014 at 6:25 PM, Daniel Micay <danielmi...@gmail.com> wrote: > On 22/06/14 06:37 AM, Matthieu Monrocq wrote: > > I am not a fan of having wrap-around and non-wrap-around types, because > > whether you use wrap-around arithmetic or not is, in the end, an > > implementation detail, and having to switch types left and right > > whenever going from one mode to the other is going to be a lot of > > boilerplate. > > > > Instead, why not take the same road than swift and map +, -, * and / to > > non-wrap-around operators and declare new (more verbose) operators for > > the rare case where performance matters or wrap-around is the right > > semantics ? > > That's the wrong default for a performance-centric language. > > > > Even though Rust is a performance conscious language (since it aims at > > displacing C and C++), the 80/20 rule still applies and most of Rust > > code should not require absolute speed; so let's make it convenient to > > write safe code and prevent newcomers from shooting themselves in the > > foot by providing safety by default, and for those who profiled their > > applications or are writing hashing algorithms *also* provide the > > necessary escape hatches. > > Reducing performance of programs making heavy use of integer arithmetic > by 50%+ is unacceptable. > > > This way we can have our cake and eat it too... or am I missing > something ? > > No one will use the language after seeing that it's slower than Java by > default. > > > _______________________________________________ > Rust-dev mailing list > Rust-dev@mozilla.org > https://mail.mozilla.org/listinfo/rust-dev > > -- Clark. Key ID : 0x78099922 Fingerprint: B292 493C 51AE F3AB D016 DD04 E5E3 C36F 5534 F907
_______________________________________________ Rust-dev mailing list Rust-dev@mozilla.org https://mail.mozilla.org/listinfo/rust-dev