On 02.12.2016 00:57, Richard wrote:
> [Please do not mail me a copy of your followup]
>
> "Alf P. Steinbach" <
alf.p.stein...@gmail.com> spake the secret code
> <o1qc1t$3nc$
1...@dont-email.me> thusly:
>
>> On 01.12.2016 22:34, Richard wrote:
>>> [...] but the use of auto deduced return types
>>> for methods and functions here feels gratuitous.
>
>> There are no deduced return types in this code.
>
> OK, consider that nit picked. s/deduced/trailing/.
There is world of difference.
>> Re consistency, this code is totally consistent:
>>
>> * `void` for Pascal /procedures/ (no expression result functions).
>> * `auto` for Pascal functions (functions that return value).
>
> Again, back to the point of the audience that is reading this code.
> The fact that you had to explain your "consistency" is buttressing my
> assertion that this style is leading to less clarity and not more.
>
> When I read the code, I see some things using trailing return types
> and some things not using trailing return types.
>
> If using auto is good enough for trailing type int, why isn't it
> good enough for trailing type void?
For the very common single case of `void` functions, `auto` just adds
verbosity (for member function implementations it can drastically reduce
verbosity, but for simple `void` functions it adds wordage).
Also, as I see it it's very nice to have this class of functions singled
out visually, as with the Pascal keyword `procedure` (which had that
exact purpose: to single them out). Because in the basic meaning the
`void` functions have a very different purpose, namely to /do/ something
rather than /compute/ something. Of course it's possible to use either
class of function for the opposite purpose, with just more awkward
notation, but that's the basis – and via the C++11 and later support for
move semantics, C++ now increasingly supports the style where
computations yield function results, used in /expressions/.
Most computer scientist, I believe, view that usage as the ideal, that a
routine that computes something should return that as its function
result, and therefore agree that the C conflation of procedure and
function was a bad choice. In original C one would have to let those
procedures return `int`, either explicitly or via C implicit int. It was
ugly, the code saying something different than the intention.
> If using classic return type without auto is good enough for void,
> why isn't it good enough for int?
Singling out `void`, procedures, is doable and has a reason (which IMO
is strong and good).
Not so for `int`.
But people have argued that `int main()` is so idiomatic that it just
feels wrong and perplexing to see it expressed with `auto`. I do that
for consistency. And also, to introduce the syntax to more people. :)
Cheers!,
- Alf