5 ms·
More insane... syntax from the C++ committee. How about a readable function-like keyword, like any other self-respecting language? C++ surpassed APL and Perl by
by rurban 2y ago
More insane... syntax from the C++ committee. How about a readable function-like keyword, like any other self-respecting language? C++ surpassed APL and Perl by far already. Really, in APL there is some consistency at least.
- foota 2y agoWhy would we need a function keyword?
- 3836293648 2y agoYou don't strictly need it, but you get rid of a bunch of ambiguities in the grammar. Not that it'd solve all the ambiguities in C++. Is a<b, c>(d) a function call or two comparisons combined with the stupidest operator in the language? Impossible to know without type information. (This is also why rust has the super ugly ::<T> for generics, so that it's unambiguous)
- joe91 2y agoarray[index] is insane syntax? That's all that's being talked about here (allowing array-like indexing of parameter packs which are variadic template parameters).
- joe91 2y agobtw: you can actually write, for example, the first function as just: auto first(auto... params) { return params...[0]; } Unless I'm missing something - but the post is showing off the fact that you can index into the list of types of the parameters, as well as the parameters themselves (in which case you need full template syntax).
- rurban 2y agoWhat I said. ... as type and identifier suffix is just nonsense. A proper language would have used ... to designate varargs, and a special identifier to hold these args. Just as the macro preprocessor.
- almostgotcaught 2y agoC++ has the loudest reactionaries to syntax changes of any language community out there. Something as simple as this has 10 complainers. Imagine if someone actually proposed something radical like rust's lifetime syntax? People would be rioting in the streets. But also part of me thinks the people making these complaints don't actually write it (C++). Because if you do then you don't really care (you just pick it up eventually without thinking about it).