Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #388563
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: how to make a macro work as a single line if stmt without braces |
| Date | 2024-09-29 19:18 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <86seth28a9.fsf@linuxsc.com> (permalink) |
| References | (2 earlier) <vcn6m8$1n1vu$1@dont-email.me> <86frpk3s1u.fsf@linuxsc.com> <20240928203048.00006703@yahoo.com> <86v7yf2h8t.fsf@linuxsc.com> <20240929124835.00003ca2@yahoo.com> |
Michael S <already5chosen@yahoo.com> writes:
> On Sat, 28 Sep 2024 21:53:06 -0700
> Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>
>> Michael S <already5chosen@yahoo.com> writes:
>>
>>> On Sat, 28 Sep 2024 05:02:05 -0700
>>> Tim Rentsch <tr.17687@z991.linuxsc.com> wrote:
>>>
>>>> Andrey Tarasevich <andreytarasevich@hotmail.com> 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 {'.
Certainly having an open brace on a line by itself stands out
more than if the open brace were written at the end of an if()
or while() line.
Whether that makes it easier to see where a block starts is
something that can be measured, and also might be reader
dependent. For myself I find that having open braces on lines by
themselves interferes with my ease of reading. And that has been
true since before I ever programmed in C.
> Now, I can live with both styles, but can see why many people
> prefer style advocated by Andrey.
I've made a serious effort over the years to find out why people
who prefer the Andrey style are so definite that it is somehow
better. I have yet to get an illuminating answer to that
question. I've gotten various forms of non-answer arguments, and
what seem to me to be circular answers (like saying it is more
readable). I understand that they prefer it; I still don't
understand why they prefer it. I acknowledge your point that
they think the open brace on a line by itself somehow helps with
their reading. But I still don't understand why they think that.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
how to make a macro work as a single line if stmt without braces Mark Summerfield <mark@qtrac.eu> - 2024-09-21 07:35 +0000
Re: how to make a macro work as a single line if stmt without braces Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-09-21 08:10 +0000
Re: how to make a macro work as a single line if stmt without braces David Brown <david.brown@hesbynett.no> - 2024-09-21 10:47 +0200
Re: how to make a macro work as a single line if stmt without braces Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-09-21 12:27 -0700
Re: how to make a macro work as a single line if stmt without braces Bart <bc@freeuk.com> - 2024-09-21 21:11 +0100
Re: how to make a macro work as a single line if stmt without braces Opus <ifonly@youknew.org> - 2024-09-21 22:39 +0200
Re: how to make a macro work as a single line if stmt without braces Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-09-21 14:54 -0700
Re: how to make a macro work as a single line if stmt without braces Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-09-21 20:05 -0700
Re: how to make a macro work as a single line if stmt without braces Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-09-21 21:33 -0700
Re: how to make a macro work as a single line if stmt without braces David Brown <david.brown@hesbynett.no> - 2024-09-22 14:15 +0200
Re: how to make a macro work as a single line if stmt without braces Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-27 03:38 -0700
Re: how to make a macro work as a single line if stmt without braces David Brown <david.brown@hesbynett.no> - 2024-09-22 13:59 +0200
Re: how to make a macro work as a single line if stmt without braces Kaz Kylheku <643-408-1753@kylheku.com> - 2024-09-22 15:11 +0000
Re: how to make a macro work as a single line if stmt without braces Bart <bc@freeuk.com> - 2024-09-22 16:56 +0100
Re: how to make a macro work as a single line if stmt without braces Michael S <already5chosen@yahoo.com> - 2024-09-22 19:27 +0300
Re: how to make a macro work as a single line if stmt without braces Bart <bc@freeuk.com> - 2024-09-22 17:47 +0100
Re: how to make a macro work as a single line if stmt without braces Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-24 07:36 -0700
Re: how to make a macro work as a single line if stmt without braces Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-09-24 07:52 -0700
Re: how to make a macro work as a single line if stmt without braces David Brown <david.brown@hesbynett.no> - 2024-09-24 17:24 +0200
Re: how to make a macro work as a single line if stmt without braces Bart <bc@freeuk.com> - 2024-09-24 17:22 +0100
Re: how to make a macro work as a single line if stmt without braces Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-09-24 12:28 -0700
Re: how to make a macro work as a single line if stmt without braces Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-27 01:43 -0700
Re: how to make a macro work as a single line if stmt without braces Bart <bc@freeuk.com> - 2024-09-24 17:35 +0100
Re: how to make a macro work as a single line if stmt without braces Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-09-24 12:30 -0700
Re: how to make a macro work as a single line if stmt without braces Bart <bc@freeuk.com> - 2024-09-24 20:42 +0100
Re: how to make a macro work as a single line if stmt without braces Kaz Kylheku <643-408-1753@kylheku.com> - 2024-09-24 19:59 +0000
Re: how to make a macro work as a single line if stmt without braces Bart <bc@freeuk.com> - 2024-09-24 21:12 +0100
Re: how to make a macro work as a single line if stmt without braces Kaz Kylheku <643-408-1753@kylheku.com> - 2024-09-24 22:36 +0000
Re: how to make a macro work as a single line if stmt without braces Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-09-22 13:39 -0700
Re: how to make a macro work as a single line if stmt without braces David Brown <david.brown@hesbynett.no> - 2024-09-23 08:16 +0200
Re: how to make a macro work as a single line if stmt without braces Richard Harnden <richard.nospam@gmail.invalid> - 2024-09-23 08:06 +0100
Re: how to make a macro work as a single line if stmt without braces David Brown <david.brown@hesbynett.no> - 2024-09-23 11:14 +0200
Re: how to make a macro work as a single line if stmt without braces Richard Harnden <richard.nospam@gmail.invalid> - 2024-09-23 11:37 +0100
Re: how to make a macro work as a single line if stmt without braces David Brown <david.brown@hesbynett.no> - 2024-09-23 14:22 +0200
Modern text editor - 'bout time someone paid attention to keeping the thread title relevant!!! (Was: how to make a macro work as a single line if stmt without braces) gazelle@shell.xmission.com (Kenny McCormack) - 2024-09-22 16:03 +0000
Re: how to make a macro work as a single line if stmt without braces David Brown <david.brown@hesbynett.no> - 2024-09-22 18:03 +0200
Re: how to make a macro work as a single line if stmt without braces Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-28 05:02 -0700
Re: how to make a macro work as a single line if stmt without braces Michael S <already5chosen@yahoo.com> - 2024-09-28 20:30 +0300
Re: how to make a macro work as a single line if stmt without braces Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-28 21:53 -0700
Re: how to make a macro work as a single line if stmt without braces Michael S <already5chosen@yahoo.com> - 2024-09-29 12:48 +0300
Re: how to make a macro work as a single line if stmt without braces Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-29 19:18 -0700
Re: how to make a macro work as a single line if stmt without braces Alan Mackenzie <acm@muc.de> - 2024-09-30 15:05 +0000
Re: how to make a macro work as a single line if stmt without braces Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-09-28 21:02 -0700
Re: how to make a macro work as a single line if stmt without braces Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-28 22:47 -0700
Re: how to make a macro work as a single line if stmt without braces Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-09-29 07:41 -0700
Re: how to make a macro work as a single line if stmt without braces Michael S <already5chosen@yahoo.com> - 2024-09-29 18:04 +0300
Re: how to make a macro work as a single line if stmt without braces scott@slp53.sl.home (Scott Lurndal) - 2024-09-29 18:30 +0000
Re: how to make a macro work as a single line if stmt without braces Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-09-29 16:39 -0700
Re: how to make a macro work as a single line if stmt without braces Kaz Kylheku <643-408-1753@kylheku.com> - 2024-09-30 02:29 +0000
Re: how to make a macro work as a single line if stmt without braces Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-09-30 11:26 +0200
Re: how to make a macro work as a single line if stmt without braces Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-29 18:39 -0700
Re: how to make a macro work as a single line if stmt without braces Kaz Kylheku <643-408-1753@kylheku.com> - 2024-09-30 02:03 +0000
Re: how to make a macro work as a single line if stmt without braces David Brown <david.brown@hesbynett.no> - 2024-09-30 13:17 +0200
Re: how to make a macro work as a single line if stmt without braces Bart <bc@freeuk.com> - 2024-09-21 10:13 +0100
Re: how to make a macro work as a single line if stmt without braces Mark Summerfield <mark@qtrac.eu> - 2024-09-21 09:53 +0000
Re: how to make a macro work as a single line if stmt without braces Ike Naar <ike@sdf.org> - 2024-09-21 09:15 +0000
Re: how to make a macro work as a single line if stmt without braces Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-09-21 14:44 -0700
Re: how to make a macro work as a single line if stmt without braces Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-21 06:07 -0700
Re: how to make a macro work as a single line if stmt without braces Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-09-21 15:55 -0700
Re: how to make a macro work as a single line if stmt without braces Andrey Tarasevich <andreytarasevich@hotmail.com> - 2024-09-21 12:17 -0700
Re: how to make a macro work as a single line if stmt without braces Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> - 2024-09-21 21:18 +0000
Re: how to make a macro work as a single line if stmt without braces Tim Rentsch <tr.17687@z991.linuxsc.com> - 2024-09-24 06:18 -0700
csiph-web