Juha Nieminen <nospam@thanks.invalid>: Nov 10 07:03AM >> Designated initializers aren't needed. There are constructors. > To my surprise, I agree. In fact, I thought everyone agreed on this, > and that that's why it wasn't squeezed into C++11. For and while loops aren't needed either, nor switch constructs, nor templates, or even classes. Or pretty much anything. Even C is way too high level and has way too many useless features. A programming language with just two instructions is Turing complete, and thus you can implement anything with it. Nothing more is needed. |
"Christian Hanné" <the.hanne@gmail.com>: Nov 10 08:31AM +0100 > For and while loops aren't needed either, nor switch constructs, nor > templates, or even classes. ... That's polemic. We're talking about dropping a less usable feature for a more usable. |
David Brown <david.brown@hesbynett.no>: Nov 10 10:46AM +0100 On 09/11/2020 21:24, Jorgen Grahn wrote: >> Designated initializers aren't needed. There are constructors. > To my surprise, I agree. In fact, I thought everyone agreed on this, > and that that's why it wasn't squeezed into C++11. Certainly constructors can cover many of the use-cases of designated initializers. And clearly constructors can do far more than designated initializers can do. But in many simple cases, designated initializers are simply easier and more convenient in the code. They are not /needed/ - but neither is 90%+ of C++ /needed/. They are /wanted/. It is a commonly requested feature, and has been supported as an extension by some C++ compilers for quite a while. |
David Brown <david.brown@hesbynett.no>: Nov 10 10:48AM +0100 On 10/11/2020 08:31, Christian Hanné wrote: >> templates, or even classes. ... > That's polemic. > We're talking about dropping a less usable feature for a more usable. No, we are not. We are talking about /adding/ a useful feature to C++ - a feature that exists already and is useful in C. No one is dropping anything. |
"Christian Hanné" <the.hanne@gmail.com>: Nov 10 12:36PM +0100 > No, we are not. > We are talking about /adding/ a useful feature to C++ - a feature that > exists already and is useful in C. No one is dropping anything. That's not necessary because we have constructors. |
David Brown <david.brown@hesbynett.no>: Nov 10 01:46PM +0100 On 10/11/2020 12:36, Christian Hanné wrote: >> We are talking about /adding/ a useful feature to C++ - a feature that >> exists already and is useful in C. No one is dropping anything. > That's not necessary because we have constructors. Do you realise your posts are making no sense, and your arguments don't hang together? If the answer is yes, you are trolling - and there's no point in continuing. If the answer is no, you are not capable of holding a sensible discussion and there's no point in continuing. |
"Christian Hanné" <the.hanne@gmail.com>: Nov 10 01:51PM +0100 > hang together? If the answer is yes, you are trolling - and there's no > point in continuing. If the answer is no, you are not capable of > holding a sensible discussion and there's no point in continuing. The discussion is superfluous because we have constructors instead of designated initializers. |
Juha Nieminen <nospam@thanks.invalid>: Nov 10 01:13PM > /needed/ - but neither is 90%+ of C++ /needed/. They are /wanted/. It > is a commonly requested feature, and has been supported as an extension > by some C++ compilers for quite a while. In fact, designated initializer can be combined with constructors (or with any functions for that matter) in order to, effectively, get named function parameters where all of them can have default values and you can override any of them with a different value. In other words, you could have something along the lines of: struct MyClassParams { int firstValue = 0, secondValue = 10; float someFloat = 0.0, anotherFloat = 5.0; const char* name = nullptr; }; MyClass::MyClass(const MyClassParams& params) { ... } You could then, ostensibly, instantiate the class like: MyClass obj({ .secondValue = 15, .name = "Fancy Name" }); (If there are any mandatory parameters, they could be specified as their own function parameters before that MyClassParams parameter.) |
Jorgen Grahn <grahn+nntp@snipabacken.se>: Nov 10 09:41PM On Tue, 2020-11-10, Juha Nieminen wrote: > high level and has way too many useless features. A programming > language with just two instructions is Turing complete, and thus you > can implement anything with it. Nothing more is needed. I see you're not interested in a serious discussion. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o . |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment