Path: ...!3.eu.feeder.erje.net!feeder.erje.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Michael S Newsgroups: comp.lang.c Subject: Re: how to make a macro work as a single line if stmt without braces Date: Sun, 29 Sep 2024 12:48:35 +0300 Organization: A noiseless patient Spider Lines: 51 Message-ID: <20240929124835.00003ca2@yahoo.com> References: <86frpk3s1u.fsf@linuxsc.com> <20240928203048.00006703@yahoo.com> <86v7yf2h8t.fsf@linuxsc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Injection-Date: Sun, 29 Sep 2024 11:48:06 +0200 (CEST) Injection-Info: dont-email.me; posting-host="b1c937c2e7b01fb16cab4b41feb8475c"; logging-data="1802069"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX198qmz7kLdcBx07jR1Deo6UUz/H6qDN7vs=" Cancel-Lock: sha1:CRYrbFE97cr37owKgWrUPsTyoi8= X-Newsreader: Claws Mail 3.19.1 (GTK+ 2.24.33; x86_64-w64-mingw32) Bytes: 2826 On Sat, 28 Sep 2024 21:53:06 -0700 Tim Rentsch wrote: > Michael S writes: > > > On Sat, 28 Sep 2024 05:02:05 -0700 > > 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? > > > > { at the same level of indentation as its matching } > > Certainly it is true that the layout style shown has the open > brace at the same level of indentation as the matching close > brace. What about that property makes this layout "more > readable"? The statement given sounds like a tautology - > I don't see that any new information has been added. It makes it easier to see where block starts and where it ends. Opening { followed by empty line is more bold visually than 'if something { ' or then '} else {'. Now, I can live with both styles, but can see why many people prefer style advocated by Andrey.