Groups | Search | Server Info | Login | Register
Groups > comp.lang.c > #390923
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Which code style do you prefer the most? |
| Date | 2025-03-09 11:41 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <867c4yujvw.fsf@linuxsc.com> (permalink) |
| References | (1 earlier) <20250304175602.c9fe683d678d3a2ed101a4ac@g{oogle}mail.com> <vq75k8$1t6ut$2@dont-email.me> <vq785i$1u7v7$1@dont-email.me> <20250304101022.154@kylheku.com> <vq7shq$226p3$1@dont-email.me> |
Richard Harnden <richard.nospam@gmail.invalid> writes:
> On 04/03/2025 18:14, Kaz Kylheku wrote:
>
>> On 2025-03-04, bart <bc@freeuk.com> wrote:
>>
>>> The style I use for generated code is like this:
>>>
>>> if (cond) {
>>> stmt1;
>>> }
>>> else {
>>> stmt2;
>>> }
>>
>> I've been known to do this:
>>
>> if (case_ineligible_for_switch) {
>> // ...
>> } else switch (state_variable) {
>> // ...
>> }
>>
>> or
>>
>> if (case_not_requiring_loop) {
>> // ...
>> } else for (;;) {
>> // ...
>> }
>>
>> and I might even have historically perpetrated something like:
>>
>> if (case_not_requiring_loop) {
>> // ...
>> } else if (case_requiring_loop) for (;;) {
>> // ...
>> } else {
>> // ...
>> }
>
> I like the brace on its own line. It visually separates the
> condidition from the statement.
If someone wants visual separation, that can be done just
as well or better with a blank line.
> How do people format long and complex conditions, given that
> you're trying not to a much over 80 columns?
In almost all cases, revise the code so that conditions in if(),
while(), etc, result in a line not over 80 columns. There are
various ways of doing this, such as factoring the condition into a
function, introducing auxiliary variables for sub-conditions, and so
forth.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
Re: Which code style do you prefer the most? Anton Shepelev <anton.txt@g{oogle}mail.com> - 2025-03-04 17:56 +0300
Re: Which code style do you prefer the most? Richard Heathfield <rjh@cpax.org.uk> - 2025-03-04 15:18 +0000
Re: Which code style do you prefer the most? bart <bc@freeuk.com> - 2025-03-04 16:01 +0000
Re: Which code style do you prefer the most? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-04 18:14 +0000
Re: Which code style do you prefer the most? Richard Harnden <richard.nospam@gmail.invalid> - 2025-03-04 21:49 +0000
Re: Which code style do you prefer the most? Richard Heathfield <rjh@cpax.org.uk> - 2025-03-04 22:17 +0000
Re: Which code style do you prefer the most? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-04 22:26 +0000
Re: Which code style do you prefer the most? Richard Heathfield <rjh@cpax.org.uk> - 2025-03-04 22:40 +0000
Re: Which code style do you prefer the most? Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-03-04 23:45 +0000
Re: Which code style do you prefer the most? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-05 05:46 +0100
Re: Which code style do you prefer the most? vallor <vallor@cultnix.org> - 2025-03-05 07:02 +0000
Re: Which code style do you prefer the most? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-05 09:35 +0100
Re: Which code style do you prefer the most? Richard Heathfield <rjh@cpax.org.uk> - 2025-03-05 08:39 +0000
Re: Which code style do you prefer the most? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-05 09:58 +0100
Re: Which code style do you prefer the most? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-05 19:12 +0000
Re: Which code style do you prefer the most? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-05 21:53 +0100
Re: Which code style do you prefer the most? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-06 01:22 +0000
Re: Which code style do you prefer the most? Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-03-06 02:34 +0000
Re: Which code style do you prefer the most? Anton Shepelev <anton.txt@g{oogle}mail.com> - 2025-03-05 15:22 +0300
Re: Which code style do you prefer the most? David Brown <david.brown@hesbynett.no> - 2025-03-05 14:44 +0100
Re: Which code style do you prefer the most? Richard Heathfield <rjh@cpax.org.uk> - 2025-03-05 14:20 +0000
Re: Which code style do you prefer the most? Anton Shepelev <anton.txt@g{oogle}mail.com> - 2025-03-05 18:30 +0300
Re: Which code style do you prefer the most? bart <bc@freeuk.com> - 2025-03-05 16:40 +0000
Re: Which code style do you prefer the most? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-05 18:09 +0100
Re: Which code style do you prefer the most? Richard Harnden <richard.nospam@gmail.invalid> - 2025-03-05 17:32 +0000
Re: Which code style do you prefer the most? scott@slp53.sl.home (Scott Lurndal) - 2025-03-05 17:51 +0000
Re: Which code style do you prefer the most? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-05 19:50 +0100
Re: Which code style do you prefer the most? richard@cogsci.ed.ac.uk (Richard Tobin) - 2025-03-05 19:09 +0000
Re: Which code style do you prefer the most? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-05 19:18 +0000
Re: Which code style do you prefer the most? Richard Heathfield <rjh@cpax.org.uk> - 2025-03-05 20:07 +0000
Re: Which code style do you prefer the most? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-05 21:46 +0100
Re: Which code style do you prefer the most? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-05 14:58 -0800
Re: Which code style do you prefer the most? David Brown <david.brown@hesbynett.no> - 2025-03-06 10:35 +0100
Re: Which code style do you prefer the most? David Brown <david.brown@hesbynett.no> - 2025-03-06 10:29 +0100
Re: Which code style do you prefer the most? scott@slp53.sl.home (Scott Lurndal) - 2025-03-06 14:49 +0000
Re: Which code style do you prefer the most? Richard Harnden <richard.nospam@gmail.invalid> - 2025-03-06 17:52 +0000
Re: Which code style do you prefer the most? Richard Heathfield <rjh@cpax.org.uk> - 2025-03-06 18:05 +0000
Re: Which code style do you prefer the most? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-06 21:14 +0000
Re: Which code style do you prefer the most? David Brown <david.brown@hesbynett.no> - 2025-03-07 15:37 +0100
Re: Which code style do you prefer the most? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-07 12:17 -0800
Re: Which code style do you prefer the most? David Brown <david.brown@hesbynett.no> - 2025-03-08 16:47 +0100
Re: Which code style do you prefer the most? candycanearter07 <candycanearter07@candycanearter07.nomail.afraid> - 2025-03-12 22:20 +0000
Re: Which code style do you prefer the most? Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2025-03-12 15:23 -0700
Re: Which code style do you prefer the most? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-13 00:12 +0000
Re: Which code style do you prefer the most? David Brown <david.brown@hesbynett.no> - 2025-03-13 09:30 +0100
Re: Which code style do you prefer the most? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-13 09:44 +0000
Re: Which code style do you prefer the most? Michael S <already5chosen@yahoo.com> - 2025-03-13 16:19 +0200
Re: Which code style do you prefer the most? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-13 16:20 +0100
Re: Which code style do you prefer the most? David Brown <david.brown@hesbynett.no> - 2025-03-06 20:36 +0100
Re: Which code style do you prefer the most? G <g@nowhere.invalid> - 2025-03-07 09:28 +0000
Re: Which code style do you prefer the most? Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-03-07 21:16 +0000
Re: Which code style do you prefer the most? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-06 20:49 +0000
Re: Which code style do you prefer the most? Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-03-05 22:02 +0000
Re: Which code style do you prefer the most? bart <bc@freeuk.com> - 2025-03-05 23:46 +0000
Re: Which code style do you prefer the most? Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-03-06 00:46 +0000
Re: Which code style do you prefer the most? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-06 10:53 +0100
Re: Which code style do you prefer the most? scott@slp53.sl.home (Scott Lurndal) - 2025-03-06 14:48 +0000
Re: Which code style do you prefer the most? Kaz Kylheku <643-408-1753@kylheku.com> - 2025-03-06 21:18 +0000
Re: Which code style do you prefer the most? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-07 08:10 +0100
Re: Which code style do you prefer the most? Lawrence D'Oliveiro <ldo@nz.invalid> - 2025-03-04 23:36 +0000
Re: Which code style do you prefer the most? Tim Rentsch <tr.17687@z991.linuxsc.com> - 2025-03-09 11:41 -0700
Re: Which code style do you prefer the most? Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-03-05 05:21 +0100
csiph-web