Path: csiph.com!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: Is this safe? Date: Wed, 22 Feb 2023 09:17:14 -0800 Organization: None to speak of Lines: 38 Message-ID: <87pma1pqlh.fsf@nosuchdomain.example.com> References: <86k009bqyu.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Info: reader01.eternal-september.org; posting-host="99cab6dae2753796a2705b653d9ad57c"; logging-data="1658757"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18gIxA6wt9ryxboTpvhzrEL" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Cancel-Lock: sha1:+MTWM/o+cf26Isag4cYGZEloA4o= sha1:eR4Yu0Rl/sCZftGgpRroyFHcElw= Xref: csiph.com comp.lang.c++:89208 Tim Rentsch writes: > 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. I prefer the "int *foo;" spacing (conventional in C) because it follows the syntax, but the "int* foo;" spacing has become a convention in C++ (probably because Stroustrup uses it in his books), and I use it in C++ for that reason. I also avoid declarations where it would make a difference to a human reader, like "int* foo, bar;". Most development is on existing code. It would be poor practice to use the "better" spacing on new code while leaving the existing code (which most likely uses the C++ conventional spacing) as it is. It would also be poor practice to change all the spacing in a large body of existing code. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com Working, but not speaking, for XCOM Labs void Void(void) { Void(); } /* The recursive call of the void */