3 ms·
But why remove them? What's wrong with declaring int i at the top of your function (like old-style C) and then using it throughout all loops in the function? Y
by 72deluxe 4y ago
But why remove them? What's wrong with declaring int i at the top of your function (like old-style C) and then using it throughout all loops in the function?
You can't just cull old variadic functions because some old stuff won't work. It's easy to say "just get rid of it!" but that's never going to happen because it's backwards compatible. People really should be using parameter packs now instead of old variadics but I have worked with "developers" who hadn't a clue about them. The senior developers dismissed the new features as syntactic sugar and insisted on writing old-style code. They detested std::pair. They were unaware of move semantics. An rvalue reference was unknown. Lambdas were pointless to them.
It also isn't in Bjarne's hands - it's the committee. He fought against various things (as I recall from his talks at cppcon) but they ended up in the language anyway.
- tgv 4y ago> What's wrong with declaring int i at the top of your function (like old-style C) and then using it throughout all loops in the function? Ask Stroustrup. It's his example, and in this case avoidable. > You can't just cull old variadic functions because some old stuff won't work. Yes, you can. They've removed quite a few features from older C++ versions. You can turn them back on, if you want. So for C++x24 or whatever, they could say: for loop variables are always local, C variadic is no longer permitted, etc., and use some compiler flag to re-enable it. > It also isn't in Bjarne's hands But that's probably the person with most influence on the language. And if he would propose a C++safer version, which deviates from the standard by eliminating as many bad practices as he sees fit, people would follow, and the two would probably merge at some point. But that won't happen, which makes the core guidelines a bit of a joke. "Here's an apple. Don't eat it."
- 72deluxe 4y agoGood points. I myself would be happy to see va_args disappear but it'd require work from the maintainers of the compilers etc. which is unlikely to get support, I guess?