News for hackers. Stuff that matters.
Re:C23 is finished: Here is what is on the menu by einpoklum on Friday August 05, 2022 @07:59AM (#32354860)
This is a misunderstanding of C++ principles, not an anti-C++ rant.

In C++, it is intentionally not straightforward to know what code gets called when a statement is executed - even without namespaces. We have:

* Function overloads

* Non-trivial (and not-built-in) implicit conversions

* Non-trivial copy and move constructors

* Template and concept resolution, which can be tricky

* Operator overloads, so that foo[n] or bar() may do something very different than what you expect.

And if you add in macros to the mix, you can really go crazy. For example, in this SO answer: https://stackoverflow.com/a/70328397/1593077 I explain how to implement an infix operator which lets us write:

    int x = whatever();
    if ( x is_one_of {1, 3, 42, 7, 69, 550123} ) {
        do_stuff(x);
    }
C is simply not that kind of language (well, macros notwithstanding I suppose).
Re:C23 is finished: Here is what is on the menu by jstimpfle on Friday August 12, 2022 @04:33AM (#32435901)
This is nice if your goal is to come up with convoluted ways to say the same thing in fewer characters (ignoring the code that you had to add to enable the shorter version in the first place).

With your example, both a switch and simple if-else chains would be perfectly readable and also easy to write.