June 11, 2026
Brace yourself for argument drama
Faking keyword arguments to functions in C++
C++ tries on Python’s best trick, and the comments instantly turned into a nerd fight
TLDR: A developer shared a way to make C++ function calls read more like Python by passing labeled settings instead of a confusing list of values. Commenters immediately split between “this is old news or fake” and “this is actually the cleanest way to handle lots of options,” with plenty of pedantry and jokes in between.
A programmer showed off a clever workaround for giving C++ something that feels a lot like Python-style named arguments — basically, writing function calls in a way that’s easier for humans to read. The trick uses a little container of settings with labels, so instead of memorizing a long list of values in order, you can say what each value means. It’s not a brand-new feature, and wow, the commenters were very ready to point that out. One of the loudest reactions was basically, “Excuse me, this is ancient history,” with people rushing in to remind everyone that the labeled-field idea comes from older C standards and only arrived in C++ more recently.
But the real popcorn moment was the split between the “this is fake and a little clunky” crowd and the “who cares, it’s clean and practical” camp. Some readers rolled their eyes at the extra braces and said this isn’t “real” keyword arguments at all — one even launched into a mini language-police rant over whether these should be called keyword or named arguments. Others were completely unbothered, saying they already prefer the “options struct” approach whenever a function has lots of optional settings, because it’s easier to read and doesn’t force you to juggle values in the right order.
And because no coding thread can remain normal for long, someone took the conversation on a wild detour into fantasy land: custom operators like 5 <xor> 3. Another commenter joked that the whole thing feels like programming has somehow gone full circle back to old-school habits. In other words: one neat coding trick, and the community reaction was a glorious mix of nitpicking, nostalgia, and “honestly, this kind of rules.”
Key Points
- •The article contrasts Python's native keyword arguments with the absence of that feature in C and C++.
- •It states that adding true keyword arguments to C++ would likely take many years of language-standard effort.
- •Previous attempts to simulate keyword arguments in C++ using macros and template techniques are described as not widely adopted.
- •The proposed approach is to have a function accept a single struct parameter.
- •Callers can use designated initializers to set selected struct fields while other fields retain default values, creating syntax that resembles keyword arguments.