Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Tim Rentsch
Newsgroups: comp.lang.c
Subject: Re: how to make a macro work as a single line if stmt without braces
Date: Sat, 28 Sep 2024 22:47:16 -0700
Organization: A noiseless patient Spider
Lines: 48
Message-ID: <86r0932eqj.fsf@linuxsc.com>
References: <86frpk3s1u.fsf@linuxsc.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Date: Sun, 29 Sep 2024 07:47:19 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="af077a0b22884ed040881afe1a29036e"; logging-data="1736048"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18KYZWh+EBdCkuMZK6Zwc4AeW8jth58hgo="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:IzvC326r6A2eg+ZPw3IJXMh+4Y4= sha1:YgK8hjtOEtHd3mHMYbOKJGWsjJU=
Xref: csiph.com comp.lang.c:388550
Andrey Tarasevich writes:
> On 09/28/24 5:02 AM, Tim Rentsch wrote:
>
>> Andrey Tarasevich writes:
>>
>> [...]
>>
>>> And don't use "Egyptian" braces [the style used in the
>>> first edition of The C Programming Language, by Kernighan
>>> and Ritchie].
>>>
>>> This is the proper formatting style with braces
>>>
>>> if (failed)
>>> {
>>> ...
>>> }
>>> else
>>> {
>>> ...
>>> }
>>>
>>> The vertical spacing introduced by the `{` line provides
>>> separation between condition and the branch, which makes
>>> your code much more readable. [...]
>>
>> What qualities does this layout style have that make it "more
>> readable", other than it being one that you like or prefer?
>
> Er... The answer to his question is already present in the quoted
> portion of my post. "The vertical spacing introduced..."
Does that mean you think this
if (failed) {
...
} else {
...
}
is just as readable? Or is it something besides the
vertical spacing that bears on your "more readable"
judgment?