| Deutsch English Français Italiano |
|
<vpp3bo$30vqa$1@dont-email.me> 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: Janis Papanagnou <janis_papanagnou+ng@hotmail.com>
Newsgroups: comp.lang.c
Subject: Re: Which code style do you prefer the most?
Date: Thu, 27 Feb 2025 08:14:00 +0100
Organization: A noiseless patient Spider
Lines: 69
Message-ID: <vpp3bo$30vqa$1@dont-email.me>
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=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Feb 2025 08:14:01 +0100 (CET)
Injection-Info: dont-email.me; posting-host="7a301de3e08edcb10ceefde6c0f3fc75";
logging-data="3178314"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zHshsx7ZKW1JoW9hjYAqV"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:QkymfmT+7fV1UE0h7nMaveiYamc=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <7wJvP.420809$yI2a.217056@fx42.iad>
Bytes: 2902
On 26.02.2025 19:59, Scott Lurndal wrote:
> 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.
Yes. :-)
>
> if (flag && (state == 42)) state = 73;
> else statement;
>
> :-)
>
Though my preference would probably be somewhere in between, given
that there's certainly a reason why the 'case' had been used; for
example for an extension on many branches. So probably more like
if (flag) {
switch (state)
{
case 42:
state = 73;
break;
}
} else {
statement;
}
But I'd also have no problems with
if (flag && (state == 42))
state = 73;
else
statement;
to better see the structure, and to avoid too many padding blanks,
and of course also to avoid too long lines ;-)
Janis