3 ms·
How about just different operators for different intents? Like prepending a special symbol in front of an operator to make it behave differently.
by zzzcpan 11y ago
How about just different operators for different intents? Like prepending a special symbol in front of an operator to make it behave differently.
- eridius 11y agoThe article already mentioned the idea of using separate operators to control this behavior, similarly to how Swift has a separate set of operators for wrapping arithmetic.
- pcwalton 11y agoThat's discussed in the article. "The current state isn’t necessarily the final state of overflow checking: the RFC even mentioned some future directions. Rust could introduce operators like Swift’s wrapping +% in future, something that was not done initially because Rust tries to be conservative and reasonably minimal, as well as hypothetically having scoped disabling of overflow checking (e.g. a single function could be explicitly marked, and its internals would thus be unchecked in all modes). There’s interest in the latter particularly, from some of Rust’s keenest (potential) users Servo and Gecko."
- zzzcpan 11y agoYes, I know. But more operators is the solution, it removes all that ambiguity with multiple intents and simplifies a lot of things.
- masklinn 11y agoThere are already methods for all intents, and while (as noted in TFA) it's possible wrapping gets an operator, it's really unlikely that saturating or checked would get one.