On 3/2/2017 7:05 PM, Mr Flibble wrote:
> On 02/03/2017 02:49, Alf P. Steinbach wrote:
>>
>> Well, you can help improve it. :) E.g., try to be clear about why one,
>> in your opinion, should never mix new stuff with old stuff, if that's
>> the point here? Because I just don't see it, it's not meaningful to me.
>
> First we can consider terseness:
>
> int main() // 10 characters (including whitespace)
> auto main() -> int // 18 characters (including whitespace)
>
> Less characters can be grokked quicker by the brain.
No doubt that is true in some situations.
And I agree that the most frequently used things should be shortest, as
a rule.
But `main` is not so much used that a few characters is a problem: in a
million function program there's only 1 `main`.
> Secondly we can consider rationale:
>
> The trailing return type syntax was invented to solve a problem related
> to templates
This is probably true. Wikipedia uses the example of letting the return
type be the promoted type of arguments. Andrei Alexendrescu wrote ¹an
article investigating how to do that properly for C++03, and it was
messy indeed – but then, C++03 didn't have `decltype`.
> and very few people think ALL functions should use it;
This is probably also true, just as very few people in the world, less
than 10%, think there is no supernatural deity or deities.
As religion to a large degree proves, the majority can't be counted on
to have an opinion that coincides with rational thinking for any given
question, until they've been convinced by non-rational arguments. In
particular, I believe, until they've been convinced that the rational
position is what people in their social group think. Then they're likely
to adopt the rational position, but not because it's rational.
At that point their opinion should /also/ be ignored. ;-)
> certainly not main() which is IDIOMATICALLY DEFINED.
Now this is rubbish, I'm sorry to tell you.
I think you mean that using the old syntax for declaring `main` is an
idiom, on account having been used exclusively for 40 years or so.
But an idiom in programming is a common way to do something, chosen from
/other possible ways/, and due to its frequent use probably a good
enough choice for most any situation. For example, the erase + remove
idiom in C++, as opposed to other ways of doing that, or the copy + swap
idiom for copy assignment operator implementation in C++, as opposed to
other ways of doing that. What other ways were there for the `main`
function syntax?
> You deliberately try to frustrate and irritate
And this telepathic insight into my motivations for whatever I do, is
also rubbish.
Don't trust your feelings, Leigh.
> by obtusely writing legal but obfuscated C++
And this is just not true as fact: it's probably your impression, and so
it's probably a true, heartfelt statement from you, but it's not true as
fact.
>; why do you do this?
Disregarding the inferred nefarious motivations for using trailing
return type, there remains the question of why you evidently perceive
code with trailing return type syntax to be “legal but obfuscated C++”.
I think you, who have this perception, is the only one who can answer that.
Cheers!,
- Alf
Links:
¹ <url:
http://www.drdobbs.com/generic-min-and-max-redivivus/184403774>