Yea. And there's even pitfalls the author didn't list. My biggest pet peeve about C++ default arguments it that they are compile time inserted based on the header file. So imagine:
void foo(int a = 1) {}
Now you ship this in a DLL, but realize the default was bad, so you change it to 2 and ship the new DLL. Well, the 1/2 isn't in the DLL at all. It's only in the header file. So everyone must recompile. Fun times.
Technically that's a subtly incompatible ABI change. ABI changes can be notoriously tricky to spot. That's handled properly on an ELF-based system by bumping the SONAME major (if the library developer knows what they're doing) but that won't help non-ELF platforms or vendored uses.
Of course, the same problem applies in other languages if a constant value changes. A preprocessor macros in C, for example. It's all about non-manifest interfaces and "making things easier" so that any idiot can write software (so they do). Public APIs can be hard when the public is imperfect.
Comments
All C++ specific though right? Trying to imagine the insanity that would be Numpy (or xyz other Scipy lib) without default function args ...
Yea. And there's even pitfalls the author didn't list. My biggest pet peeve about C++ default arguments it that they are compile time inserted based on the header file. So imagine:
void foo(int a = 1) {}
Now you ship this in a DLL, but realize the default was bad, so you change it to 2 and ship the new DLL. Well, the 1/2 isn't in the DLL at all. It's only in the header file. So everyone must recompile. Fun times.
Technically that's a subtly incompatible ABI change. ABI changes can be notoriously tricky to spot. That's handled properly on an ELF-based system by bumping the SONAME major (if the library developer knows what they're doing) but that won't help non-ELF platforms or vendored uses.
Of course, the same problem applies in other languages if a constant value changes. A preprocessor macros in C, for example. It's all about non-manifest interfaces and "making things easier" so that any idiot can write software (so they do). Public APIs can be hard when the public is imperfect.
Yea, that's what I said. And it's subtle because of the language making it a foot gun.
That's just C++ the apologist talking.