| Deutsch English Français Italiano |
|
<861pvfyha4.fsf@linuxsc.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch <tr.17687@z991.linuxsc.com>
Newsgroups: comp.lang.c
Subject: Re: Which code style do you prefer the most?
Date: Sun, 02 Mar 2025 00:21:23 -0800
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <861pvfyha4.fsf@linuxsc.com>
References: <vpkmq0$21php$1@dont-email.me> <vpl2k4$24fmt$1@dont-email.me> <20250225104754.267@kylheku.com> <878qps2abs.fsf@onesoftnet.eu.org> <20250226095615.829@kylheku.com> <7wJvP.420809$yI2a.217056@fx42.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Sun, 02 Mar 2025 09:21:23 +0100 (CET)
Injection-Info: dont-email.me; posting-host="3262fa73ab11de5fd8cc37f0606a7eed";
logging-data="746144"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+mK2r1ZBxzD11qERNRN/8A4GpHq5YahJw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:PutuEwsCJisjbVq7WeEOSFNO0mY=
sha1:5xxv/N9QE99RXgeTUiYFaRBBUBg=
Bytes: 2468
scott@slp53.sl.home (Scott Lurndal) writes:
> Kaz Kylheku <643-408-1753@kylheku.com> writes:
>
>> On 2025-02-26, Ar Rakin <rakinar2@onesoftnet.eu.org> wrote:
>>
>>> Sorry, I should have showed this difference in my original post.
>>> I like the GNU style except the weird indentation before the
>>> braces of control statements. Not sure why they choose to indent
>>> that way.
>>>
>>> The GNU style without indent before braces looks nice to me.
>>
>> Without the weird brace indent, it has nothing to do with GNU any
>> more; it's just two-space indentation, where opening braces are on
>> their own line instead of being "cuddled" into the previous line,
>> which is very common:
>>
>> if (flag)
>> {
>> switch (state)
>> {
>> case 42:
>> {
>> state = 73;
>> break;
>> }
>> }
>> }
>> else
>> {
>> statement;
>> }
>
> There's so much vertical space wasted in that, however.
>
> if (flag && (state == 42)) state = 73;
> else statement;
The suggested rewrite has different semantics. Instead
if(flag) state = state == 42 ? 73 : state;
else statement;
or
if(flag) state != 42 || (state = 73);
else statement;
has the same behavior as the original. (Disclaimer: not
compiled.)