[TUHS] What would early alternatives to C have been?

arnold at skeeve.com arnold at skeeve.com
Mon Mar 10 19:12:06 AEST 2025


Larry McVoy <lm at mcvoy.com> wrote:

> > Parentheses around expressions were required in our coding style.
>
> Good for you, we were the same.  It's not that hard to make the code
> easier to read.

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.  That said, when mixing && and ||, I do
parenthesize:

	if ((a == b && c == d) || (p == q && x == y))

If there are lots of OR conditions, I break lines:

	if (   (a == b && c == d)
	    || (e == f && g == h)
	    || (i == j && k == l)
	    || (p == q && x == y))

I will also use parentheses with the bitwise operators.

As in many things related to style, taste and judgement are needed, not
just slavish adherence to instructions without any understanding of them.
My two cents.

Arnold

(P.S. Don't get me started on `if (NULL == pointer)' and `if (42 != foo)'.
Grrrr...)


More information about the TUHS mailing list