-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Add note about pre/post increment to the design FAQ. #23186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
What about |
|
||
## Why no `--x` or `x++`? | ||
|
||
Pre- and post- increment, while convenient, are also fairly complex. They |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre- and post- increment
I'm not sure, but that space after "post-" looks wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I felt slightly awkward about it, but it felt more consistent. Maybe I should just re-word and write 'increment' twice
@killercup |
|
||
Pre- and post- increment, while convenient, are also fairly complex. They | ||
require knowledge of evaluation order, and often lead to subtle bugs and | ||
undefined behavior in C and C++. `x = x + 1` and `x = x - 1` is only slightly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d go for x += 1
and x -= 1
here, because they’re both shorter and their meaning looks, at least to me, closer to the increment and decrement ops.
8ea2883
to
a600899
Compare
⌛ Testing commit a600899 with merge 621ccf5... |
Fixes #14686