logoalt Hacker News

C++26: The Oxford Variadic Comma

62 pointsby ingvelast Wednesday at 7:27 AM28 commentsview on HN

Comments

rusakov-fieldtoday at 8:21 PM

Clarity and Elegance of Syntax > Backwards compatibility.

In my opinion anyway. C++ feels so bloated these days.

staplungtoday at 6:43 PM

Of course since the old syntax is merely deprecated and not removed, going forward you now have to know the old, bad form and the new, good form in order to read code. Backwards compatibility is a strength but also a one-way complexity ratchet.

At least they managed to kill `auto_ptr`.

show 2 replies
mFixmantoday at 6:22 PM

I used to slay with this in code golfing competitions from TopCoder, where you had to implement a function to solve a particular problem, thanks to C pointer maths and the gcc generally putting function arguments in order in the stack.

Turns out, these two are equivalent in practice (but UB in the C++ standard):

    double solve(double a, double b, double c, double d) {
      return a + b + c + d;
    }

    double solve(double a ...) {
      return a + 1[&a] + 2[&a] + 3[&a];
    }
show 3 replies
advaeltoday at 6:22 PM

This seems pretty good to me just on the level of trying to read C as someone using C++. Parameter packs and variadic templates are easily the most confusing syntax in C++ and cleaning it up is... very welcome

show 1 reply
blueaquilaetoday at 7:59 PM

I'm far from C++ but reading this article confused be, from the form to the impact to the dead link https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p12...

I guess that's a preview how C++ require a lifelong commitment.

zlfntoday at 6:46 PM

C++ seems to be constantly getting complicated. If the major version were to change, there wouldn't be any need for backward compatibility with the existing code, and it would have been okay to delete that syntax while creating an automatic formatter.

show 1 reply
lasgawetoday at 6:29 PM

learned something new. thanks for the article.

HackerThemAlltoday at 7:07 PM

Yes, but no. I learned C++ in '90s when it was C with classes and some other noise added by Stroustrup. During the some 25 years that followed it had became a mess that's insanely hard to work with. I'm not going back to this language. I prefer plain C or Rust, leaning towards Rust when I fully comprehend the lifetime and borrow checker. Or when I have the luxury of having a GCed runtime, then the .NET with its easiest C# language with wonderful abundance of great libraries is the best choice. Nobody was ever fired for using .NET (for right purposes).

throwaway2027today at 6:34 PM

C++ got too complicated after C++23 I went back to C.

show 3 replies