Discussion
C++26: The Oxford variadic comma
advael: 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
mFixman: 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]; }
jkaplowitz: Hats off for using "..." in your comment immediately after a valid identifier word and with no comma in between, given the topic of the article.
camel-cdr: K&R syntax is -1 char, if you are in C: 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];} double solve(a,b,c,d)double a,c,b,d;{return a+b+c+d;}
lasgawe: learned something new. thanks for the article.
staplung: 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.
zlfn: 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.
dnmc: Are you suggesting we move to C++++?
zlfn: It's already there. It's called C#
m-schuetz: Personally I like C+. Picking the nice parts of C++, but skipping all the nonsense. I just wish C++ hadn't deliberately screwed up designated initializers with mandatory ordering. The C version of it that allows out-of-order assignments is clearly superior.
advael: Hats off for noticing. Not to be taken for granted in an increasingly skimming-oriented world
HackerThemAll: Well, C# also has its quirks already. Like the crippled finalizers which are never to be used. If the IDisposable interface had been correctly designed, finalizers could become be the "public void Dispose(void)". Or the manual passing of Task in case of async methods, which is... kinda smelly.
tialaramex: It's possible you didn't realise, but C# is sometimes said to be named that way because # is the symbol you get if you draw ++ small and then on the line below ++ again. Hence C++++All languages have some spikier edges, there are no languages I know where I think "Well, even if we could start over I have no idea how to improve this". What's notable about C++ is just how rich that "could do better" seam is, so very many of their defaults are wrong, so many of their keywords are the wrong word, so many of their standard library features are allowed, sometimes even mandated to be crap.
blueaquilae: 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.
HackerThemAll: I think you meant to get that to the original poster, who seems to imply C# is the flawless, bestest incarnation of C\+\+(\+\+)+.
Joker_vD: double solve(double a[]) { return 0[a] + 1[a] + 2[a] + 3[a]; } solve((double[]){1, 2, 3, 4}); The cast in the invocation can be macro-ed away. And the best thing is, the actual stack layout and data movement/shuffling is pretty much identical to the approach with <stdargs.h>, and with no UB or compiler intrinsics.