On Mon, Mar 10, 2025 at 11:12 AM Larry McVoy <lm@mcvoy.com> wrote:
> On Mon, Mar 10, 2025 at 10:52:20AM -0400, Clem Cole wrote:
> > On Mon, Mar 10, 2025 at 10:41???AM Larry McVoy <lm@mcvoy.com> wrote:
> > > On Mon, Mar 10, 2025 at 03:12:06AM -0600, arnold@skeeve.com wrote:
> > > > I think, as in all things, "always use parentheses" can be carried
> > > > too far. I find
> > > >
> > > > if (a == b && c == d)
> > > >
> > > > perfectly reasonable, but
> > > >
> > > > if ((a == b) && (c == d))
> > > >
> > > > to be just silly.
> > >
> > > Color me silly then.
> >
> > Me too.
> >
> > > My eyes parse the "silly" form faster.
> >
> > Exactly.
> >
> > > And I was the boss so my eyes won. Over time, everyone at my shop came
> > > to agree with me.
> > > One mans silly is another mans faster reading.
> > >
> > The problem is that in the first form, you have to slow down to ensure you
> > have the order correctly, Maybe it's my dyslexia speaking, but the "extra"
> > parens make it clear without having to slow down.
>
> Exactly. It's not that Clem and I are stupid, we aren't.
Oh goodness; I hope we can all agree that no one was suggesting that!
Yea. That's the problem with style debates: It's all about taste, preference and workflow. Those items differ wildly, are core to one's identity (to a degree not usually appreciated) and so it turns personal w/o people intending it to do so. I saw a presentation years ago that went over all the human factors and showed that there's too many 80/20 60/40 divides in how people's brains work to have a universal style that would be friction free for everybody. I searched for it just now, but couldn't find it.
I'm team "If you want that many parens, use LISP" not team "Explicit parens make it clearer" myself, but as you see, my internal framing isn't exactly respectul while trying to be funny... Another hazard of style debates.
> [snip] creates pointless work for other people.
Along these lines, I can't stand when people write, `if (!strcmp(a,
b)) { /* strings are equal */ }`
While true, I find the negation particularly annoying in this context,
and prefer either `if (strcmp(a, b) == 0) { ... }` or writing a small
`streq()` function that returns boolean true/false.
There's a number of things in C that we'd do differently in other languages... FreeBSD encourages the latter style over the former and is an odd choice of concise and verbose when it comes to notation (sometimes delete the extra parens, sometimes have extra == 0 or != 0).
Warner