←back to thread

The C23 edition of Modern C

(gustedt.wordpress.com)
397 points bwidlar | 1 comments | | HN request time: 0s | 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(6): >>41850960 #>>41851047 #>>41851166 #>>41851693 #>>41853183 #>>41855660 #
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 #
card_zero ◴[] No.41851532[source]
People seem to mostly write a typical for loop ending with ; ++i){

But I write ; i++){ and seeing it the other way round throws me off for a minute, because I think, as you put it, why would you use those very particular semantics?

But I guess this is only a semantic argument.

replies(4): >>41851721 #>>41852277 #>>41852443 #>>41852595 #
1. secondcoming ◴[] No.41852595{5}[source]
It makes no difference if the increment is done on an int, but it can make a different if your `i` is some object with its own ++ operator.