cmp icon indicating copy to clipboard operation
cmp copied to clipboard

cleanup: Start of no-implicit-bool compliance; use prefix-increment.

Open iphydf opened this issue 10 months ago • 1 comments

Semantics of postfix-increment are to return the value it had before the increment, encouraging code like f(..., b++), which is better written as f(..., b); ++b; to avoid doing too many possibly mutating operations in one statement/expression.

I've put one of the no-implicit-bool cleanups in this PR, because it's the only one that requires CMP_NULL and an addition to the CI to continue supporting C++ as a compile target for cmp.c (it does today, and I don't want to break that). There are a number of implicit bool conversions, some of which are probably bugs, so I'll send a separate PR to fix those.

iphydf avatar Apr 05 '24 13:04 iphydf

I try to keep the C++-isms to a minimum in CMP and I'm not convinced of the benefits here. I did pull in the CI changes (thanks!), but I think unless there are errors in C++ compilers that can only be fixed by switching from idiomatic C to idiomatic C++ I don't think this is necessary. Could be convinced though!

camgunz avatar Apr 14 '24 12:04 camgunz

Ok, I've reverted the CMP_NULL change for now, keeping the prefix-incr change and moving a local variable to a deeper scope (still C89 compatible).

iphydf avatar May 01 '24 10:05 iphydf

OK I can live with that, thanks for doing it :)

camgunz avatar May 03 '24 12:05 camgunz