TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 229 subscribers
Post #24130 26
Positive Logic vs Indentation

This came up today in a code review and I'm seriously wondering other people's
opinions.

Basically the code was this (inside a function):
if (a && (b || c || d)) {
// Some statements here
}


And the reviewer said: Consider changing that if to return early so that we
can reduce indentation making the code more readable.

Fair enough, let's apply DeMorgan:
if (!a || (!b && !c && !d)) {
return;
}

// Some statements here


I myself like a lot better the first version since it deals with positive
logic
which is a lot clearer for me, I can read that as a sentence and
understand it completely while the second version I need to stop for a minute to
reason about all those negations!

https://redd.it/1oibqxa
@r_cpp
Reddit From the cpp community on Reddit Explore this post and more from the cpp community
More from @r_cpp
  1. Oct 14, 2026I tested whether a coding agent would use C++23 ranges without being told Blog post: https…
  2. Oct 14, 2026C++ futures part 1: The mental model https://devblogs.microsoft.com/oldnewthing/20261012-0…
  3. Oct 14, 2026C++ futures part 2: The mental model for std::promise, std::packaged_task https://devblogs…
  4. Oct 12, 2026[Release] slick-logger v2.2.0 — Lock-free asynchronous C++20 logging with multi-process sh…
  5. Oct 12, 2026Cheap alternative to reboot parameters (nohz, rcu, isolcpus) for stable benchmarks When no…
  6. Oct 12, 2026This C++ drama is crazy - Adobe votes no https://www.youtube.com/watch?v=DEqx_NMMH9Q https…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →