←back to thread

The C23 edition of Modern C

(gustedt.wordpress.com)
411 points bwidlar | 1 comments | | HN request time: 0.198s | source
Show context
belter ◴[] No.41850897[source]
Important reminder just in the Preface :-)

Takeaway #1: "C and C++ are different: don’t mix them, and don’t mix them up"

replies(7): >>41850960 #>>41851047 #>>41851166 #>>41851693 #>>41853183 #>>41855660 #>>41857019 #
jpcfl ◴[] No.41851047[source]
Bjarne should have called it ++C.
replies(2): >>41851328 #>>41854437 #
card_zero ◴[] No.41851328[source]
Because people choose to use pre-increment by default instead of post-increment?

Why is that?

replies(4): >>41851427 #>>41851557 #>>41851650 #>>41853498 #
jejdjdbd ◴[] No.41851427[source]
Why would you use post increment by default? The semantics are very particular.

Only on very rare occasions I need post increment semantics.

And in those cases I prefer to use a temporary to make the intent more clear

replies(3): >>41851532 #>>41852965 #>>41856255 #
1. flohofwoe ◴[] No.41856255[source]
I rarely use pre-increment tbh, but post-increment all the time for array indices (since typically the array should be indexed with the value before the increment happens).

If the pre- or post-increment behaviour isn't actually needed, I prefer `x += 1` though.