Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Tim Rentsch Newsgroups: comp.lang.c Subject: Re: Coding style for small if statements Date: Tue, 18 Feb 2020 02:09:03 -0800 Organization: A noiseless patient Spider Lines: 40 Message-ID: <86tv3odx6o.fsf@linuxsc.com> References: <20200131234613.59047e037939ceb549b8e6d6@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="d9b0a35ddf05bf8591aa2d3738ff843a"; logging-data="23728"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qtQkeHbqm4ZoqvYgxQoiMkoDGxPXauqw=" User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux) Cancel-Lock: sha1:ze/nQ4a6Z8pXVbar/ca6oDYHF+Q= sha1:vu1h1Wh7jHfut45JPnpqDeWuPBw= Xref: csiph.com comp.lang.c:150071 Guillaume writes: > Le 31/01/2020 at 21:46, Anton Shepelev a ecrit: > >> [...] [example providing context next:] >> >> if (dblh != dblw) { >> if (dblh) >> gfx_flags |= GFX_DBL_H; >> } else { >> gfx_flags |= GFX_DBL_W; >> } > > Small digression: > Not to trigger a flamewar here, I know this is a topic for potentially > heated debate here (coding style almost always is), but I personally > just hate the opening braces at the end of lines. This style has > become pervasive. I think it initially comes from the Kernighan & > Richie style, which granted were the authors of C, but we have to keep > in mind that in the 70's, screen estate was really at a premium, so it > saved extra lines. These days, it's not really justified anymore and > it just makes it look like block delimiters are an annoyance rather > than a feature - I for one just don't agree with this point. And I > like to keep my things aligned. End of digression anyway - there > really seems to be two camps there with pretty aggressive positions. I don't want to take part in any flamewar, but I would like to ask: Can you say why you prefer open braces placed elsewhere beyond just that you don't like them there? I have asked about this (that is, putting open braces on different lines) several times in the past and the only answers I've gotten seem to me to be circular. So I am interested to hear if you can explain your reaction or reasons further. Incidentally, the K&R bracing style didn't become pervasive, it has always been pervasive since the early days of C. And I am pretty sure it wasn't because of small screens that people chose this way of writing. I know it wasn't for me, and I've been programming since the days of small screens (and in fact even before that).