Re: style change: explicitly permit braces for single statements

2020-08-03 Thread Chris Hanson
On Jul 12, 2020, at 9:31 PM, Greg A. Woods wrote: > > Personally I don't think there's any good excuse for not always putting > braces around all single-statement blocks. The only bad execuse is that > the language doesn't strictly require them. People are lazy, I get that > (I am too), but in

Re: style change: explicitly permit braces for single statements

2020-08-01 Thread Luke Mewburn
I've decided not to pursue this any further. No objections if anyone else wants to take up the cause. On 20-07-17 23:20, Alistair Crooks wrote: | Just to get back to the original subject - fully support {} around single | statements - have been doing that in my own code for ages. | |

Re: style change: explicitly permit braces for single statements

2020-07-18 Thread Alistair Crooks
Just to get back to the original subject - fully support {} around single statements - have been doing that in my own code for ages. Would be great to have that codified (ha!) On Thu, 16 Jul 2020 at 12:01, Rhialto wrote: > On Thu 16 Jul 2020 at 13:08:49 -0400, Ted Lemon wrote: > > It sounds

Re: style change: explicitly permit braces for single statements

2020-07-16 Thread Ted Lemon
On Jul 16, 2020, at 12:16 PM, Gerhard Sittig wrote: > Text line length does matter to those of us who put several > copies of code side by side. It sounds like we need a better tool. FWIW, when actually working on code, I’ve found that 120 is a better width than 80—with 80, there are just too

Re: style change: explicitly permit braces for single statements

2020-07-16 Thread Gerhard Sittig
On Mon, 2020-07-13 at 09:18 -0700, Greg A. Woods wrote: > > At Mon, 13 Jul 2020 09:48:07 -0400 (EDT), Mouse > wrote: > Subject: Re: style change: explicitly permit braces for single statements > > > > Slavishly always > > adding them makes it difficult to keep co

Re: style change: explicitly permit braces for single statements

2020-07-16 Thread Rhialto
On Thu 16 Jul 2020 at 13:08:49 -0400, Ted Lemon wrote: > It sounds like we need a better tool. FWIW, when actually working on > code, I've found that 120 is a better width than 80 -- with 80, there are > just too many line breaks. But I don't mean to say that your > preference is wrong -- what

Re: style change: explicitly permit braces for single statements

2020-07-16 Thread Mouse
> E.g. web browsers just reflow the text when you change the window > width. Why don=E2=80=99t we have this for code editors? Short answer: try to build it and you'll see. Longer answer: Because the exact layout of `words' affects readability of code far more than it does running text.

Re: style change: explicitly permit braces for single statements

2020-07-13 Thread Mouse
>> if (ch == t.c_cc[VINTR]) { >> } else { >> if (ch == t.c_cc[VQUIT]) { >> } else { >> if (ch == t.c_cc[VKILL]) { >> } else { >> } >> } >> } > For this, I would prefer > if

Re: style change: explicitly permit braces for single statements

2020-07-13 Thread Greg A. Woods
At Mon, 13 Jul 2020 09:48:07 -0400 (EDT), Mouse wrote: Subject: Re: style change: explicitly permit braces for single statements > > Slavishly always > adding them makes it difficult to keep code from walking into the right > margin: These days one really should consider the

Re: style change: explicitly permit braces for single statements

2020-07-13 Thread Johnny Billquist
On 2020-07-13 17:52, Paul Goyette wrote: if (ch == t.c_cc[VINTR]) {     ...do INTR processing... } else {     if (ch == t.c_cc[VQUIT]) {     ...do QUIT processing...     } else {     if (ch == t.c_cc[VKILL]) {     ...do KILL processing...   

Re: style change: explicitly permit braces for single statements

2020-07-13 Thread Paul Goyette
if (ch == t.c_cc[VINTR]) { ...do INTR processing... } else { if (ch == t.c_cc[VQUIT]) { ...do QUIT processing... } else { if (ch == t.c_cc[VKILL]) {

Re: style change: explicitly permit braces for single statements

2020-07-13 Thread Rhialto
On Mon 13 Jul 2020 at 09:48:07 -0400, Mouse wrote: > I'd actually recommend one exception, that being the else-if chain: if > the dependent clause after an else is a single statement, and it is an > if statement, then, depending on the semantic relationship of the inner > if's test to the

Re: style change: explicitly permit braces for single statements

2020-07-13 Thread Mouse
>> I find the braces pure visual clutter in the latter. > What really bugs me is when my code winds up with a security fail because I $ Yeah, that bugs me too. But "don't be careless" isn't something codifiable enough to go on a list of style rules such as this one. > â??Because it looks

Re: style change: explicitly permit braces for single statements

2020-07-13 Thread Joerg Sonnenberger
On Mon, Jul 13, 2020 at 09:18:18AM -0400, Ted Lemon wrote: > On Jul 13, 2020, at 9:13 AM, Mouse wrote: > > . I find the braces pure visual clutter in the latter. > > What really bugs me is when my code winds up with a security fail because I > wasn’t careful. If only we had compilers that

Re: style change: explicitly permit braces for single statements

2020-07-13 Thread Ted Lemon
On Jul 13, 2020, at 9:13 AM, Mouse wrote: > . I find the braces pure visual clutter in the latter. What really bugs me is when my code winds up with a security fail because I wasn’t careful. I’ve had this happen maybe three or four times in my career, which isn’t too bad, but it’s hard to

Re: style change: explicitly permit braces for single statements

2020-07-13 Thread Mouse
> Personally I don't think there's any good excuse for not always > putting braces around all single-statement blocks. Well, you may not think it good, but I prefer if (x < 0) return(n); to if (x < 0) { return(n); } . I find the braces pure visual clutter in the latter. I

re: style change: explicitly permit braces for single statements

2020-07-13 Thread matthew green
> On 20-07-12 10:01, Luke Mewburn wrote: > | I propose that the NetBSD C style guide in to /usr/share/misc/style > | is reworded to more explicitly permit braces around single statements, > | instead of the current discourgement. > | > | IMHO, permitting braces to be consistently used: >

Re: style change: explicitly permit braces for single statements

2020-07-12 Thread Greg A. Woods
At Sun, 12 Jul 2020 10:01:36 +1000, Luke Mewburn wrote: Subject: style change: explicitly permit braces for single statements > > I propose that the NetBSD C style guide in to /usr/share/misc/style > is reworded to more explicitly permit braces around single statements, > instead of

Re: style change: explicitly permit braces for single statements

2020-07-12 Thread Michael Cheponis
A few years ago when I worked at Tesla, we had to have our production code pass a MISRA C linter: https://gimpel.com/ MISRA C requires braces even with a single clause. I'm not going to try to justify MISRA C's rules; but only say that 'programmers in automobile / embedded' world probably find

Re: style change: explicitly permit braces for single statements

2020-07-12 Thread Robert Elz
Date:Sun, 12 Jul 2020 13:01:59 +1000 From:Luke Mewburn Message-ID: <20200712030159.gh12...@mewburn.net> | | IMHO, permitting braces to be consistently used: | | - Adds to clarity of intent. | | - Aids code review. | | - Avoids gotofail:

Re: style change: explicitly permit braces for single statements

2020-07-11 Thread Nick Hudson
On 12/07/2020 04:01, Luke Mewburn wrote: On 20-07-12 10:01, Luke Mewburn wrote: | I propose that the NetBSD C style guide in to /usr/share/misc/style | is reworded to more explicitly permit braces around single statements, | instead of the current discourgement. | | IMHO,

Re: style change: explicitly permit braces for single statements

2020-07-11 Thread Michael van Elst
p...@whooppee.com (Paul Goyette) writes: >Another +1 here. The "add another statement" is frequently "add a >debug_printf()" and many is the time i've broken an if statement by >adding debug code. { debug_printf(); } works and doesn't get forgotten before committing. I personally find

Re: style change: explicitly permit braces for single statements

2020-07-11 Thread Luke Mewburn
On 20-07-12 10:01, Luke Mewburn wrote: | I propose that the NetBSD C style guide in to /usr/share/misc/style | is reworded to more explicitly permit braces around single statements, | instead of the current discourgement. | | IMHO, permitting braces to be consistently used: | - Adds

Re: style change: explicitly permit braces for single statements

2020-07-11 Thread Paul Goyette
On Sun, 12 Jul 2020, Valery Ushakov wrote: Luke Mewburn wrote: I propose that the NetBSD C style guide in to /usr/share/misc/style is reworded to more explicitly permit braces around single statements, instead of the current discourgement. IMHO, permitting braces to be consistently used: -

Re: style change: explicitly permit braces for single statements

2020-07-11 Thread Valery Ushakov
Luke Mewburn wrote: > I propose that the NetBSD C style guide in to /usr/share/misc/style > is reworded to more explicitly permit braces around single statements, > instead of the current discourgement. > > IMHO, permitting braces to be consistently used: > - Adds to clarity of intent. > - Aids

Re: style change: explicitly permit braces for single statements

2020-07-11 Thread David Holland
On Sun, Jul 12, 2020 at 10:01:36AM +1000, Luke Mewburn wrote: > I propose that the NetBSD C style guide in to /usr/share/misc/style > is reworded to more explicitly permit braces around single statements, > instead of the current discourgement. concur Really, there should always be braces

style change: explicitly permit braces for single statements

2020-07-11 Thread Luke Mewburn
I propose that the NetBSD C style guide in to /usr/share/misc/style is reworded to more explicitly permit braces around single statements, instead of the current discourgement. IMHO, permitting braces to be consistently used: - Adds to clarity of intent. - Aids code review. - Avoids gotofail: