Path: csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c++
Subject: Re: Is this safe?
Date: Wed, 22 Feb 2023 08:32:57 -0800
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <86k009bqyu.fsf@linuxsc.com>
References:
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader01.eternal-september.org; posting-host="ac4e296fa9b47119c23b6ef4a9f9b2b8"; logging-data="1652283"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+tavyb3zvXZKQt7j9AYBJF8eKxJuJXw3Q="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:uHO4dFLbiSRHIPrry2OR1mZSeN4= sha1:SwnT+7uYaQGCG19vkv8WGqRXEV8=
Xref: csiph.com comp.lang.c++:89207
Andrey Tarasevich writes:
> On 02/21/23 6:12 AM, Alf P. Steinbach wrote:
>
>> Not what you're asking, but the common convention in C++ is to
>> separate the type specification from the variable, i.e. `auto& c`
>> not `auto &c`.
>>
>> But on the third and gripping hand, in this case I'd write `char&
>> c`, since there's no advantage in `auto` here and it obscures
>> things.
>
> Not really. This is a misleading "convention" that has no reason to
> exist. In this case the `&` is a part of an individual declarator,
> not a part of decl-specifier-seq. There's no reason to group the
> syntactic elements differently. It achieves nothing.
I would say it achieves less than nothing, because it's misleading.
It's like writing a+b * c ; the grouping suggested by the spacing
doesn't match the actual precedence. In almost all cases it's a
mistake to use "contra-syntactic" spacing, and attaching '&' or '*'
to a type specifier is definitely one of those mistakes.